diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish index 74ec1cf04..3b745341c 100644 --- a/share/functions/__fish_config_interactive.fish +++ b/share/functions/__fish_config_interactive.fish @@ -29,14 +29,14 @@ function __fish_config_interactive -d "Initializations that should be performed # The default just prints a variable of the same name. # # NOTE: This status check is necessary to not print the greeting when `read`ing in scripts. See #7080. - if status is-interactive + if not status is-interactive-read and functions -q fish_greeting fish_greeting end # Display SHELL_WELCOME if set. This is a standard environment variable (introduced by # systemd v257) intended for shells to display when they first initialize. - if status is-interactive + if not status is-interactive-read and set -q SHELL_WELCOME[1] string join -- ' ' $SHELL_WELCOME end diff --git a/tests/checks/tmux-read.fish b/tests/checks/tmux-read.fish index 61274092c..a98ba5e1c 100644 --- a/tests/checks/tmux-read.fish +++ b/tests/checks/tmux-read.fish @@ -1,14 +1,16 @@ -#RUN: %fish %s +#RUN: fish=%fish %fish %s #REQUIRES: command -v tmux #REQUIRES: test -z "$CI" -isolated-tmux-start -C ' - function fish_greeting - set -l name (read) - echo hello $name - end +printf >?$__fish_config_dir/functions/fish_greeting.fish %s \ +'function fish_greeting + set -l name (read) + echo hello $name +end ' +isolated-tmux-start + isolated-tmux send-keys name Enter 'echo foo' Enter tmux-sleep isolated-tmux capture-pane -p @@ -17,3 +19,12 @@ isolated-tmux capture-pane -p # CHECK: prompt 0> echo foo # CHECK: foo # CHECK: prompt 1> + +isolated-tmux send-keys C-l 'SHELL_WELCOME=hello $fish -ic "read --prompt-str=R"' Enter +tmux-sleep +isolated-tmux send-keys C-c +tmux-sleep +isolated-tmux capture-pane -p +# CHECK: prompt 1> SHELL_WELCOME=hello $fish -ic "read --prompt-str=R" +# CHECK: R +# CHECK: prompt 2> diff --git a/tests/test_functions/isolated-tmux-start.fish b/tests/test_functions/isolated-tmux-start.fish index 0a4f75d5f..a922db5fe 100644 --- a/tests/test_functions/isolated-tmux-start.fish +++ b/tests/test_functions/isolated-tmux-start.fish @@ -41,9 +41,13 @@ function isolated-tmux-start --wraps fish set -l fish (status fish-path) set -l size -x 80 -y 10 + set -l greeting_file + if not test -f $greeting_file + printf >$__fish_config_dir/functions/fish_greeting.fish %s \ + 'function fish_greeting; end' 2>/dev/null + end isolated-tmux new-session $size -d $fish -C ' # This is similar to "tests/interactive.config". - function fish_greeting; end function fish_prompt; printf "prompt $status_generation> "; end # No autosuggestion from older history. set fish_history ""