Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: z parameter expansion flag is broken?
- X-seq: zsh-workers 41657
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx, zsh-workers@xxxxxxx
- Subject: Re: z parameter expansion flag is broken?
- Date: Sat, 9 Sep 2017 09:53:52 -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=fH+2T04EVx6N+DXBQ7apxjZ/jzJ5UAY3iLuM7B+QyUc=; b=A5fDfplrq3ZNB5auscVa4MV2JD0tFZc6wGGSzUrAaJbQEOPpa+YOhrlLEq1RS+CZk8 cDZssOJGan0EgQ1w6Y1LUxLxeYaPMODxDiLn4Em6gmViCqglPetGzHMTJhYgzq4Q5f6B uZQ3y7nq75q/u1AQtbHPtC2vClQGOxk9+ZCkDnSNEhP8BGAIQOhkaofHCNknFzttY6Yh dbplSfl+xwo1XBMXWuYFYdZABVOBeUuCeI6iN9cP0MsfbhxEIEUB4vmmaQUYiWMknbFn XlQRQfShejHIF8+7/gKrEHUY4JK5XpO7KbQ4SqKQeC65Cxf/GkMQlnKe5ne6Ye5t4NUE sB1A==
- In-reply-to: <20170909.041303.1592547893142420542.ghostrevery@gmail.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: <20170909.041303.1592547893142420542.ghostrevery@gmail.com>
On Sep 9, 4:13am, Yuya Amemiya wrote:
}
} Why does z parameter expansion flag remove leading '-' from result?
Hrm.
In the (z) case, "-" has been tokenized as DASH when bufferwords() is
called. This eventually comes down to ingetc() while reading the next
lexical word from the input buffer. At line 202 there is
202 if (itok(lastc = STOUC(*inbufptr++)))
203 continue;
Because itok(DASH) is true, we discard it and continue around the loop.
That code in ingetc() is as old as the shell itself, so I have to assume
that there's a good reason to discard token characters during lexing,
and the problem is upstream with the recently-introduced code that
more aggressively tokenizes hyphens ... though I don't understand why
other tokens haven't similarly been adversely affected (or maybe I just
haven't found how to get another token embedded in the string).
In any case this is a really serious bug; it's not just leading "-" that
get removed:
torch% print -r -- ${(z):--a -b -c d-e-f}
a b c def
Messages sorted by:
Reverse Date,
Date,
Thread,
Author