From db46c9cd5844240fb6015666c8e2a12a0a3a6ead Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 9 Sep 2021 20:05:39 +0100 Subject: 49353: Fix comments in sourced file. If the file was sourced from an interactive shell with INTERACTIVE_COMMENTS not set, comments were not parsed. Note there is a remaining edge case where the sourced file is in fact entered at the comment line. --- ChangeLog | 5 +++++ Src/exec.c | 2 +- Test/A01grammar.ztst | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b295af2c9..878299d12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2021-09-09 Peter Stephenson + + * 49353: Src/exe.c, Test/A01grammar.ztst: In sourced file, + always parse comments normally, ignoring INTERACTIVE_COMMENTS. + 2021-09-08 Bart Schaefer * 49391: Doc/Zsh/zle.yo: document default bracketed-paste bindings diff --git a/Src/exec.c b/Src/exec.c index 79d8064b6..1f23a862d 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -4622,7 +4622,7 @@ getoutput(char *cmd, int qt) char *s; int onc = nocomments; - nocomments = (interact && unset(INTERACTIVECOMMENTS)); + nocomments = (interact && !sourcelevel && unset(INTERACTIVECOMMENTS)); prog = parse_string(cmd, 0); nocomments = onc; diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst index 88fc8606e..c114ff103 100644 --- a/Test/A01grammar.ztst +++ b/Test/A01grammar.ztst @@ -944,3 +944,12 @@ F:Note that the behaviour of 'exit' inside try-list inside a function is unspeci if : ${(e)a}; then echo x; fi 1:Status on bad substitution in if without else ?(eval):2: bad substitution + + echo 'echo foo # comment + echo $( + echo bar # comment + )' >source_comments.zsh + $ZTST_testdir/../Src/zsh -f -o extendedglob -is -c '. ./source_comments.zsh' +0:Comments should be handled in command subst in interactively sourced files +>foo +>bar -- cgit 1.4.1