[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

printf octal literals

From: Dan Douglas
Subject: printf octal literals
Date: Mon, 05 May 2014 06:09:22 -0500
User-agent: KMail/4.13 (Linux/3.14.0-pf1+; KDE/4.13.0; x86_64; ; )

Just a heads up on something I hadn't noticed: Bash (and dash) treat
octal literals in printf precision inconsistently (using glibc -- not
sure if it's a bug or GNUism on that end or the shell):

    $ bash -c 'printf "<%.010d> <%.*d>\n" 1 010 1'
    <0000000001> <00000001>

Zsh is also inconsistent, but in the reverse direction:

    $ zsh -c 'printf "<%.010d> <%.*d>\n" 1 010 1'
    <00000001> <0000000001>

ksh93 of course follows its usual pattern of ignoring octal literals

    $ ksh -c 'printf "<%.010d> <%.*d>\n" 1 010 1'
    <0000000001> <0000000001>

(...and if everybody else follows suit, they won't be missed. Worked out
fine for ECMAScript5 strict.)

Dan Douglas

reply via email to

[Prev in Thread] Current Thread [Next in Thread]