From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11948 invoked by alias); 10 Dec 2015 01:52:19 -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: 37368 Received: (qmail 341 invoked from network); 10 Dec 2015 01:52:18 -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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, HTML_MESSAGE,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=QfS0Fe5wdqZ8ZE92foVWVkAu/r6ZO2gwrOfpOrZOyCM=; b=q0wnoukTb0xm/rCPzgf9AszndYe5011gN1V66TQ5clGE75UVNFlkRwcadC2UgswWUY 1bGcKMs97ln4ljcGjeTsjQjyZWyU1nMfi3fsbC+61IGD8V8wGnA01fMiCxA3d88AHCG4 AjrchUQ2DL0+M8EZcx1GxwEnkZpd5rlqG1zNop673hipbIYIeG3lnOLylKP88Q0k/avi whny/7dp9tba2NIQy74bFUUh9vV9vXYCBUcCjYvIK/T7WlA7MB0fosnerttR55boKO7Y YkEOo1IFuB6cdE3ej/2aRcnqBoPR9U/GrBui++FQ0fQ8SVK+sBXWaCH9yp68uv1RV1Rw NqBw== MIME-Version: 1.0 X-Received: by 10.50.73.106 with SMTP id k10mr5988572igv.84.1449712336261; Wed, 09 Dec 2015 17:52:16 -0800 (PST) Date: Thu, 10 Dec 2015 12:22:16 +1030 Message-ID: Subject: expr length "$val" returns the wrong length for values containing NULL (\\0) From: D Gowers To: zsh-workers@zsh.org Content-Type: multipart/alternative; boundary=089e013a0e02d4561c0526817453 --089e013a0e02d4561c0526817453 Content-Type: text/plain; charset=UTF-8 Test case: v=$(printf foo\\0bar);expr length "$v";expr length $v alternatively: v=foo$'\0'bar;expr length "$v";expr length $v In zsh, the values returned are 3 and 3. In dash and zsh, the values returned are 6 and 6. Both of those results are wrong, AFAICS (foo$'0'bar is 7 characters long). But the zsh result is more severely wrong. I could understand the bash/dash result, at least, as 'NULL characters are not counted towards length'. In any case, it is easily demonstrated that the string is not 3 characters long, by running 'echo "$V"' or 'print "$v"' or 'echo ${#v}' `zsh --version` = 'zsh 5.2 (x86_64-unknown-linux-gnu)' --089e013a0e02d4561c0526817453--