From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25581 invoked by alias); 24 Nov 2014 21:18:52 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19428 Received: (qmail 18980 invoked from network); 24 Nov 2014 21:18:41 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=FmBU8nqjOaAiky1OT6F88IGi//9JAAGd6cmm/SKjxSA=; b=Nhs2DTqWcSdkJxlaHQSGQyoQAGXoD/6TvfKF7PqOjUOtK9Loq0Y90rL8a7JA+0tMUK LjFhQbIhjjBIYJhnjLoi9/M68AJyabpO2Wbi2ijar1B4UHzs22Z+Bk4tA6Oml6nnuizF NbJTkmXE9KYT30nzkwdd+684STzv+KwgmpsT/qaLv1PnMKgiWtKlUiFztC0Lan5axGuc OvrhB00MCQroVQbKquDV9g3u1joJGEBybv9/JTsT3QlrWO8moo21mvXBYcQyE70RsZ5E 2oWB/U0/DcYHLuSogHd2lsVMc74pyfhLDDeEBauvf7AteTEd9lmY4//7ifVv+0vShuV6 kSNg== X-Received: by 10.194.93.168 with SMTP id cv8mr38956557wjb.114.1416863912649; Mon, 24 Nov 2014 13:18:32 -0800 (PST) Date: Mon, 24 Nov 2014 21:18:31 +0000 From: Stephane Chazelas To: Peter Stephenson Cc: Zsh hackers list Subject: Re: ${^var} and word splitting Message-ID: <20141124211831.GA17829@chaz.gmail.com> Mail-Followup-To: Peter Stephenson , Zsh hackers list References: <20141124095637.GA5716@chaz.gmail.com> <20141124111201.161d8cf2__23261.8202259347$1416827641$gmane$org@pwslap01u.europe.root.pri> <20141124152628.GA5749@chaz.gmail.com> <20141124155524.0739b3ec__26419.4987401881$1416845250$gmane$org@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141124155524.0739b3ec__26419.4987401881$1416845250$gmane$org@pwslap01u.europe.root.pri> User-Agent: Mutt/1.5.21 (2010-09-15) 2014-11-24 15:55:24 +0000, Peter Stephenson: [...] > Consequently it's easy to change the behaviour in the second case... > This doesn't cause any test failures. Unless anyone has any ideas why > we do this, maybe we should simplify it like this? If anyone does have > ideas, we should write a test for that case. [...] I'd say no. People expect: IFS=: PATH=/bin::/usr/bin setopt shwordsplit set -- $PATH to split $PATH into /bin, "" and /usr/bin. That's how all the shells (except the Bourne shell) behave (and POSIX requires) and is the whole point of having _IFS white space_ in the first place. (BTW, POSIX also requires :/bin::/usr/bin: to be split into "", "/bin", "" and "/usr/bin" (not another "") as IFS is the internal field _delimiter_ there, not _separator_. I tend to prefer the zsh way (also yash's and older versions of pdksh) though.) What I don't like much is IFS white spaces (or x's with (s:x:)) to be collapsed *but not removed from head and tail*. The whole point of having /IFS white spaces/ was to split strings the /natural/ way (like words in a text, like awk's fields or like the Bourne shell did for any character of $IFS, not just the whitespace ones). That means considering sequences of blanks as one *and* leading and trailing blanks not to create fields. A string like " : foo : bar : : baz " would be split into "", foo, bar, "" and baz. I don't see the point in doing one and not the other. IOW in: ~$ a=' a b ' zsh -c 'print -l ${(s, ,)a}' a b ~$ a=' a b ' zsh -c 'print -l "${(s, ,)a}"' a b ~$ a=' a b ' zsh -c 'print -l "${(s, ,@)a}"' a b ~$ I'd rather 2 above behave either like 1 or 2. I'm fine with 1 and 3 behave like they do now. It may be too late to change the behaviour now, though I'd find it hard to imagine people relying on "$=var" to make empty arguments at the beginning and end but not in the middle. -- Stephane