zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: bug report: INTERACTIVECOMMENTS option interacts oddly with shell functions in an interactive context
Date: Wed, 1 Sep 2021 16:17:21 +0100 (BST)	[thread overview]
Message-ID: <1399787045.1301253.1630509441777@mail2.virginmedia.com> (raw)
In-Reply-To: <20210901075543.7v2vd4vk47qw4yrr@chazelas.org>


> On 01 September 2021 at 08:55 Stephane Chazelas <stephane@chazelas.org> wrote:
> So here, I'd say:
> 
> ~$ cat a
> echo foo # comment
> echo $(
>   echo bar # comment
> )
> ~$ . ./a
> foo
> ./a:3: bad pattern: #
> 
> is clearly a bug (regression).

Yes, that does seem pretty clear.  Looks easy to fix and test.

Is there anything similar to source that might require attention?
I couldn't think of anything --- source looks like the only case
where we deflect the input from another file without starting a
new shell.

pws

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


  reply	other threads:[~2021-09-01 15:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-29 20:55 Glyph
2021-08-30 21:35 ` Bart Schaefer
2021-08-31  6:03   ` Stephane Chazelas
2021-09-01  3:41     ` Bart Schaefer
2021-09-01  7:55       ` Stephane Chazelas
2021-09-01 15:17         ` Peter Stephenson [this message]
2021-09-01 17:55           ` Bart Schaefer
2021-09-01 18:09           ` Bart Schaefer
2021-09-01 18:23             ` Stephane Chazelas
2021-09-01 18:41               ` Stephane Chazelas
2021-09-01 18:43               ` Bart Schaefer
2021-09-02  9:04             ` Peter Stephenson
2021-09-09  3:50               ` Bart Schaefer
2021-09-09 19:06                 ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1399787045.1301253.1630509441777@mail2.virginmedia.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).