From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Comment (# char) behavior in the sub-shell
Date: Sun, 10 Sep 2017 15:27:11 -0700 [thread overview]
Message-ID: <170910152711.ZM4470@torch.brasslantern.com> (raw)
In-Reply-To: <20170910210636.17bc0581@ntlworld.com>
On Sep 10, 9:06pm, Peter Stephenson wrote:
}
} I suspect this changed some versions ago now. At some point we changed
} the way we handled $(...) to parse it better.
I think this is much older than that, and has more to do with the fact
that comments are stripped out before aliases are expanded. With no
aliasing at all:
torch% echo $ZSH_VERSION
4.2.0
torch% echo $(echo 1 10 # 9)
1 10
To demonstrate that it's not related to global aliasing:
torch% alias #='echo foo'
torch% #
foo
torch% echo X $(# 1 10) Y
X Y
torch%
} It so happens we don't keep the expanded aliases from the original parse
} in the string we later replay.
If that were the only issue, then removing "#" from $histchars would not
"fix" the problem, I think?
} I'm not sure how much effort this is worth.
Using the comment delimiter as a global alias because interactive shells
don't recognize comments, certainly seems to me to be painting oneself
into a pretty tight corner case.
Still:
torch% echo $(echo $options[interactive])
on
torch%
so one might ask why no_interactive_comments does not apply.
The following changes it, and all tests still pass, but I'm relatively
sure there is something or other that it breaks.
diff --git a/Src/exec.c b/Src/exec.c
index e2432fd..4230329 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -4441,7 +4441,12 @@ getoutput(char *cmd, int qt)
pid_t pid;
char *s;
- if (!(prog = parse_string(cmd, 0)))
+ int onc = nocomments;
+ nocomments = (interact && unset(INTERACTIVECOMMENTS));
+ prog = parse_string(cmd, 0);
+ nocomments = onc;
+
+ if (!prog)
return NULL;
if ((s = simple_redir_name(prog, REDIR_READ))) {
next prev parent reply other threads:[~2017-09-10 22:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-09 16:33 Stanislav Seletskiy
2017-09-09 22:46 ` Bart Schaefer
2017-09-10 20:06 ` Peter Stephenson
2017-09-10 21:24 ` Stanislav Seletskiy
2017-09-10 22:27 ` Bart Schaefer [this message]
2017-09-11 8:49 ` Peter Stephenson
2017-09-11 9:42 ` Peter Stephenson
2017-09-20 11:54 ` Stanislav Seletskiy
2017-09-20 17:16 ` Bart Schaefer
2017-09-21 4:43 ` Stanislav Seletskiy
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=170910152711.ZM4470@torch.brasslantern.com \
--to=schaefer@brasslantern.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).