From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3686 invoked by alias); 19 Feb 2017 05:45:27 -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: 40578 Received: (qmail 11203 invoked from network); 19 Feb 2017 05:45:27 -0000 X-Qmail-Scanner-Diagnostics: from kahlil.inlv.org 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(37.59.109.123):SA:0(-0.0/5.0):. Processed in 2.865398 secs); 19 Feb 2017 05:45:27 -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=-0.0 required=5.0 tests=RP_MATCHES_RCVD autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: martijn@inlv.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at inlv.org does not designate permitted sender hosts) From: Martijn Dekker Subject: [BUG] SHWORDSPLIT: unset IFS: $* and $@ don't split To: Zsh hackers list Message-ID: <9196b7e6-2a81-37c1-c22a-e66754ea73a3@inlv.org> Date: Sun, 19 Feb 2017 06:45:38 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit In SHWORDSPLIT mode, if IFS is unset (meaning we expect default field splitting), unquoted $* and $@ (including in substitutions like ${1+$@}) or ${var-$*} do not perform the expected default field splitting after generating fields from the positional parameters. #! Src/zsh -f setopt shwordsplit set -- ab 'cd ef' gh unset -v IFS printf '[%s]\n' $* $@ Actual output: [ab] [cd ef] [gh] [ab] [cd ef] [gh] Expected output: [ab] [cd] [ef] [gh] [ab] [cd] [ef] [gh] Ref.: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_05_02 For both $@ and $*, their behaviour is only different if they are quoted. Unquoted, they behave identically: | Expands to the positional parameters, starting from one, initially | producing one field for each positional parameter that is set. When | the expansion occurs in a context where field splitting will be | performed, any empty fields may be discarded and each of the | non-empty fields shall be further split as described in Field | Splitting. Note that it says "any empty fields *may* be discarded" (not "shall" be discarded). Zsh discards them, as does nearly every other shell; yash as of 2.44 is the only one I know of that doesn't. The description at http://austingroupbugs.net/view.php?id=888 indicates the behaviour may become mandatory in the future. Thanks, - M.