Files
fish-shell/tests/checks/tmux-invocation.fish
Johannes Altmanninger 60b50afefd Fix missing ICANON regression after read in noninteractive shell
Since commit 7e3fac561d (Query terminal only just before reading
from it, 2025-09-25),

	fish -c 'read; cat'

fails to turn ICANON back on for cat.

Even before that commit, I don't know how this ever worked.  Before or
after, we'd call tcsetattr() only to set our shell modes, not the
ones for external commands (term_donate)

I also don't think there's a good reason why we set modes twice
(between term_donate () and old_modes), but I'll make a minimal (=
safer) change for now until I understand this.

The only change from 7e3fac561d was that instead of doing things in
this order:

	terminal_init()
		set_shell_modes
	read
		reader_push()
		reader_readline()
			save & restore old_modes
	cat

we now do

	read
		reader_push()
			terminal_init()
				set_shell_modes()
		reader_readline()
			save & restore old_modes
	cat

So we call set_shell_modes() just before saving modes,
which obviously makes us save the wrong thing.
Again, not sure how that wasn't a problem before.

Fix it by saving modes before calling terminal_init().

Fixes #12024
2025-11-06 13:02:23 +01:00

37 lines
825 B
Fish

#RUN: %fish %s
#REQUIRES: command -v tmux
isolated-tmux-start -C '
set -g fish (status fish-path)
'
# Implicit interactive but output is redirected.
isolated-tmux send-keys \
'$fish >output' Enter
tmux-sleep
isolated-tmux send-keys \
'status is-interactive && printf %s i n t e r a c t i v e \n' Enter \
C-d
tmux-sleep
# Extract the line where command output starts.
string match <output -r '.*\e\]133;C.*' |
string escape
# CHECK: {{.*}}interactive{{$}}
isolated-tmux send-keys \
'$fish -c "read; cat"' Enter
tmux-sleep
isolated-tmux send-keys \
'read-value ' Enter
tmux-sleep
isolated-tmux send-keys cat1 Enter
tmux-sleep
isolated-tmux send-keys cat2 Enter
tmux-sleep
isolated-tmux capture-pane -p -S 2
# CHECK: read> read-value
# CHECK: read-value cat1
# CHECK: cat1
# CHECK: cat2
# CHECK: cat2