[Top][All Lists]

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

Re: Severe Bash Bug with Arrays

From: Linda Walsh
Subject: Re: Severe Bash Bug with Arrays
Date: Fri, 27 Apr 2012 12:02:26 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/20100228 Lightning/0.9 Thunderbird/ Mnenhy/

Greg Wooledge wrote:

NEVER use eval plus a brace expansion to generate a list.  That's just
freakin' evil.  And unsafe:

But I _like_ evil sometimes!   >:->

imadev:~$ a=(lib tmp bin share '`date`')
imadev:~$ (export IFS=,;eval "echo /usr/{${a[*]}}")
/usr/lib /usr/tmp /usr/bin /usr/share /usr/Fri Apr 27 08:25:49 EDT 2012

There can be lots of such problems... I tried it on larger dirs.. parens
quote...all sorts of probs... tried embedded print "%q" ......etc

But reality is things like that save me time in typing in stuff or writing
maint scripts on my machine -- they aren't meant for handling user input.

They take hand editing to gen the paths I want and don't take user input,
so it's a specialized usage in that case....

Alternative 1:
a=(lib tmp bin share)
echo "address@hidden/#//usr/}"

Alternative 2:
a=(lib tmp bin share)
printf "/usr/%s " "address@hidden"

good points....
But I was pointing out that [*] has its place ... I use address@hidden alot
more often than [*], but will use [*], though a bit irregularly,
when I want to get the # of items in an array (where either would work)..
though I could make a case if it was worth anything to me that #..@ return
# items and #...[*] return total length of all items... but I don't really
care....and it would break all my usages of #..[*]... ;-)....

C'est la vi...

reply via email to

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