bug-bash
[Top][All Lists]
Advanced

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

Re: `printf -v foo ""` does not set foo=


From: Linda Walsh
Subject: Re: `printf -v foo ""` does not set foo=
Date: Sun, 16 Jun 2013 23:33:52 -0700
User-agent: Thunderbird

Mike Frysinger wrote:
simple test code:
        unset foo
        printf -v foo ""
        echo ${foo+set}

that does not display "set". seems to have been this way since the feature was added in bash-3.1.
-mike
----
Indeed:
set -u
unset foo
printf -v foo ""
echo $foo
bash: foo: unbound variable
foo=""
echo $foo
----
I have a feeling this would be hard to fix, since how can printf
tell the difference between
    printf -v foo ""
and
    printf -v foo
??

(with nothing after it?)  it seems the semantic parser would have already
removed the quotes by the time the args are passed to printf, even this:
set -u
printf -v foo "$(echo "$'\000'")"
echo $foo

still leaves foo gutless: without content (even if were null)





reply via email to

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