From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11547 invoked by alias); 4 Aug 2017 02:03:16 -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: 41487 Received: (qmail 23333 invoked from network); 4 Aug 2017 02:03:16 -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.718809 secs); 04 Aug 2017 02:03:16 -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) To: Zsh hackers list From: Martijn Dekker Subject: shwordsplit: final non-whitespace IFS character problem Message-ID: <0f71b764-cc3d-5274-a16a-498b792bff6e@inlv.org> Date: Fri, 4 Aug 2017 04:03:19 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit In field/word splitting, a final non-whitespace IFS delimiter character is counted as an empty field. This is unlike every other current shell (including current versions of pdksh, i.e. mksh and OpenBSD ksh). Test script: setopt shwordsplit IFS=: x=a:b: set -- $x echo $# Expected output: 2 Actual output: 3 The POSIX standard appears pretty ambiguous on this: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_05 https://osdn.jp/ticket/browse.php?group_id=3863&tid=35283#comment:3863:35283:1435293070 [click on "Show all old Histories" for complete discussion] However, it turns out that the intention of the standard was clarified back in 1995 (!) in: http://www.open-std.org/JTC1/SC22/WG15/docs/rr/9945-2/9945-2-98.html IOW, the intention of the POSIX standard is for IFS characters to be field terminators rather than separators (in spite of the S in IFS). Sorry if the timing of this is awkward (shortly before an upcoming release). Thanks, - M.