`printf -v foo ""` does not set foo=
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 signature.asc Description: This is a digitally signed message part.
Re: `printf -v foo ""` does not set foo=
On 17 June 2013 13:27, 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. Interesting. It also won't change it if it already exists, it seems: $ foo=bar $ printf -v foo "" $ echo "$foo" bar $ echo "$BASH_VERSION" 4.2.45(2)-release
Re: corrupted input after size function (input that's not recorded by bash)
Dave Gibson wrote: Trial and error suggests it's something to do with new-style command substitution. Try backticks: local s=`stty size` Yes... you are right. This works... while local s=$(stty size) does not. That's icky! I thought they were identical, they appear not to be...umm Chet??? Hello? Um... why are these not the same? local s=`stty size` local s=$(stty size) the latter seems to eat a param or similar when used in a function at an input prompt...now I wonder what other side effects "$()" has over "``" showsize() { local o="(${LINES}x${COLUMNS})" ; local s="${o//?/\\b}" ; printf "$o$s" } --- Well ain't that sweet. I thought I tried that at one point, though, and they weren't updating hmmm...proof's in the pudding, I suppose..
Re: `printf -v foo ""` does not set foo=
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)