bug-bash
[Top][All Lists]
Advanced

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

Re: printf %q represents null argument as empty string.


From: Chet Ramey
Subject: Re: printf %q represents null argument as empty string.
Date: Fri, 11 Jan 2013 16:37:56 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130107 Thunderbird/17.0.2

On 1/11/13 4:05 PM, Dan Douglas wrote:

> 
> I don't understand what you mean. The issue I'm speaking of is that printf %q 
> produces a quoted empty string both when given no args and when given one 
> empty arg. A quoted "$@" with no positional parameters present expands to 
> zero 
> words (and correspondingly for "${arr[@]}"). Why do you think "x${@}x" is 
> special? (Note that expansion didn't even work correctly a few patchsets ago.)
> 
> Also as pointed out, every other shell with a printf %q feature disagrees 
> with 
> Bash. Are you saying that something in the manual says that it should do 
> otherwise? I'm aware you could write a wrapper, I just don't see any utility 
> in the default behavior.

This is how bash behaves:

        The format is reused as necessary to consume all  of  the  argu-
        ments.  If the format requires more arguments than are supplied,
        the extra format specifications behave as if  a  zero  value  or
        null  string,  as  appropriate,  had  been supplied.

This is how Posix specifies printf to work.  I know it doesn't have %q,
but bash doesn't really differentiate between %q and %s.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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