From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3996 invoked by alias); 9 Sep 2017 16:52:36 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41657 Received: (qmail 14404 invoked by uid 1010); 9 Sep 2017 16:52:35 -0000 X-Qmail-Scanner-Diagnostics: from mail-pg0-f53.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(74.125.83.53):SA:0(-1.4/5.0):. Processed in 2.338429 secs); 09 Sep 2017 16:52:35 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_SPAM,SPF_PASS, T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=fH+2T04EVx6N+DXBQ7apxjZ/jzJ5UAY3iLuM7B+QyUc=; b=fXoP8Md2D+tuPufdZbo2ixSZGWQ+OPEx0jZ3hzAs5CILCUcpPdj9bz81yBfNbcnGTo 6adECCKynB4046mSUGqqv/vrnJnIGq+5ojn5O53TQVJY4TVMx/Ht6QHiQZul3q/liMA9 gnt4QB/ZfDRPOZTqZAH2PIRw9TE7/087eYL9vfJI7sV5SDf2iJcehjOzURzV+jJHtzKI aZNqC0u2VgulhEjGX/uDo9Eq9epKoVb3tLtJFfDIky94Ox5P/VksxiNiOd8bsRm9t59k /jZbnfElzDqVajzP7OxseFpvo7rhm0BNi0jMnYq6dv420Jf7FOqWPswwGAIA2u9+l5vG UVkg== X-Gm-Message-State: AHPjjUizXy/7vyLXXmWl1UEW4H8Boygsv3pJlbf7YBCLW87XUdxvPDTh ODOj1kz1lm8aIxaDWEE= X-Google-Smtp-Source: ADKCNb78wUGNO3W883hUrOfx1cGjlZxj+FBi0x8Zibjo8nWQQhA8ZWPhUfyn4BfZdXyeRnU/ShMQ3w== X-Received: by 10.98.178.204 with SMTP id z73mr6682421pfl.107.1504975950513; Sat, 09 Sep 2017 09:52:30 -0700 (PDT) From: Bart Schaefer Message-Id: <170909095352.ZM8398@torch.brasslantern.com> Date: Sat, 9 Sep 2017 09:53:52 -0700 In-Reply-To: <20170909.041303.1592547893142420542.ghostrevery@gmail.com> Comments: In reply to Yuya Amemiya "z parameter expansion flag is broken?" (Sep 9, 4:13am) References: <20170909.041303.1592547893142420542.ghostrevery@gmail.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org, zsh-workers@zsh.org Subject: Re: z parameter expansion flag is broken? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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