Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Comment (# char) behavior in the sub-shell
- X-seq: zsh-workers 41665
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Comment (# char) behavior in the sub-shell
- Date: Sun, 10 Sep 2017 15:27:11 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=MJKelcljstzYcGtBOWD3/ZFnJpJqsbJXK8zXxRTftqU=; b=tqts9cnWYJUKSpnAHrYBHDWixkxttQJyL53Rm2UuhMlfHSJyrfO61LA9Tcfr9xP4fD WVBHIilmsiAptHo/Mo41OWvTlOEOAK6WuKM1VcAzJ7bB8Qn9SOGoULqcqbPMl03uBlHd NjdGt8PI5KbyqzolQjJnuxjT4blIOjYFmiIW/EteRAFSVtP9u76xMmilktos2rUenzi/ bUhYOngyOCuEDavoxp3kNAfcNoC9+kDiQNM56yS7/ckow899IqU/HcBN40Z5ZntopOWa aS/RFJ2Jfb4Ith/nVn3lFrCQQIxgddOW3Znh5QMfd2kooQTHI23j+e6OKhSo49IYvWY5 6paQ==
- In-reply-to: <20170910210636.17bc0581@ntlworld.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAAR+aWfD1ifEe2JGxJAkgA5Rmpr6nmV9Ta9Y6yvW23-oe4hkYg@mail.gmail.com> <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))) {
Messages sorted by:
Reverse Date,
Date,
Thread,
Author