From 0064279905794c2f153dee68d29a32a3bbf333eb Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Thu, 4 Jun 2020 16:57:35 +0200 Subject: [PATCH] Don't show greetings in `read` in scripts This reverts commit 1b0ec2177305ed15c5a6630a0a3068dcbc64835f. "Interactive" has multiple meanings here, one of them being "the whole shell" is interactive, which `status is-interactive` tests, and one "this interaction is interactive", which happens when `read`ing in a script. Fixes #7080. --- share/functions/__fish_config_interactive.fish | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish index d53bd0935..3bea15ab1 100644 --- a/share/functions/__fish_config_interactive.fish +++ b/share/functions/__fish_config_interactive.fish @@ -114,13 +114,16 @@ function __fish_config_interactive -d "Initializations that should be performed # Print a greeting. # fish_greeting can be a function (preferred) or a variable. # - if functions -q fish_greeting - fish_greeting - else - # The greeting used to be skipped when fish_greeting was empty (not just undefined) - # Keep it that way to not print superfluous newlines on old configuration - test -n "$fish_greeting" - and echo $fish_greeting + # NOTE: This status check is necessary to not print the greeting when `read`ing in scripts. See #7080. + if status --is-interactive + if functions -q fish_greeting + fish_greeting + else + # The greeting used to be skipped when fish_greeting was empty (not just undefined) + # Keep it that way to not print superfluous newlines on old configuration + test -n "$fish_greeting" + and echo $fish_greeting + end end #