From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16205 invoked by alias); 7 Jun 2015 00:28:55 -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: 35404 Received: (qmail 9769 invoked from network); 7 Jun 2015 00:28:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,TO_NO_BRKTS_PCNT autolearn=no autolearn_force=no version=3.4.0 Message-ID: <55738EFE.1050805@inlv.org> Date: Sun, 07 Jun 2015 02:23:26 +0200 From: Martijn Dekker User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: zsh-workers@zsh.org Subject: In POSIX mode, ${#var} measures length in bytes, not characters Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit When in 'emulate sh' mode, ${#var} substitutes the length of the variable in bytes, not characters. This is contrary to the standard; the length in characters is supposed to be substituted.[*] Oddly enough, zsh is POSIX compliant here in native mode, but non-compliant in POSIX mode. Confirmed in zsh 4.3.11 (Mac OS X), 5.0.2 (Linux) and 5.0.8 (Mac OS X). $ zsh % locale LANG="nl_NL.UTF-8" LC_COLLATE="nl_NL.UTF-8" LC_CTYPE="nl_NL.UTF-8" LC_MESSAGES="nl_NL.UTF-8" LC_MONETARY="nl_NL.UTF-8" LC_NUMERIC="nl_NL.UTF-8" LC_TIME="nl_NL.UTF-8" LC_ALL= % mot=arrêté % echo ${#mot} 6 % emulate sh % echo ${#mot} 8 - Martijn [*] Reference: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02 > ${#parameter} > String Length. The length in characters of the value of parameter > shall be substituted. [...]