Unsetting all elements of an associative array

2015-02-04 Thread isabella parakiss
I'm trying to use unset array[@] to empty an associative array, but something goes wrong. This behaves as expected: $ declare -A array; array[path/directory]=value This produces an error: $ declare -A array; unset array[@]; array[path/directory]=value bash: path/directory: division by 0 (error to

Re: Unsetting all elements of an associative array

2015-02-04 Thread Greg Wooledge
On Wed, Feb 04, 2015 at 09:12:12AM +0100, isabella parakiss wrote: > I'm trying to use unset array[@] to empty an associative array, but something > goes wrong. What caused you to believe that would work? > This produces an error: > $ declare -A array; unset array[@]; array[path/directory]=value

Re: Unsetting all elements of an associative array

2015-02-04 Thread Chet Ramey
On 2/4/15 8:39 AM, Greg Wooledge wrote: > On that note, today I learned that you are not allowed to use either * > or @ as the index of an associative array in bash. What caused you to believe that would work? -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``

Re: Unsetting all elements of an associative array

2015-02-04 Thread Piotr Grzybowski
On Wed, Feb 4, 2015 at 2:39 PM, Greg Wooledge wrote: > On that note, today I learned that you are not allowed to use either * > or @ as the index of an associative array in bash. I guess I can see why, > but... that's probably going to break something some day. :) of course you can ;-) decla

Re: Unsetting all elements of an associative array

2015-02-04 Thread Greg Wooledge
On Wed, Feb 04, 2015 at 03:37:07PM +0100, Piotr Grzybowski wrote: > On Wed, Feb 4, 2015 at 2:39 PM, Greg Wooledge wrote: > > > On that note, today I learned that you are not allowed to use either * > > or @ as the index of an associative array in bash. I guess I can see why, > > but... that's pr

Re: Unsetting all elements of an associative array

2015-02-04 Thread Piotr Grzybowski
I think you are right, maybe this one should be considered: diff --git a/lib/sh/shquote.c b/lib/sh/shquote.c index fff4f81..de05f27 100644 --- a/lib/sh/shquote.c +++ b/lib/sh/shquote.c @@ -293,7 +293,7 @@ sh_contains_shell_metas (string) case '(': case ')': case '<': case '>': cas

Re: If $HISTFILE is set to /dev/null and you execute more commands than $HISTFILESIZE, /dev/null is deleted.

2015-02-04 Thread Chet Ramey
On 2/1/15 1:52 AM, Jonathan Hankins wrote: > ​Right. My concern is that a potential exploit could inject a malicious > value for HISTFILE into the environment. I think (but may be wrong) that > HISTFILE is the only codepath in a default shell invocation that could > result in a silent writing to

Re: Unsetting all elements of an associative array

2015-02-04 Thread konsolebox
On Wed, Feb 4, 2015 at 4:12 PM, isabella parakiss wrote: > This produces an error: > $ declare -A array; unset array[@]; array[path/directory]=value > bash: path/directory: division by 0 (error token is "directory") > > After unsetting all its elements, the array is not associative anymore? Logic

Re: Unsetting all elements of an associative array

2015-02-04 Thread Chet Ramey
On 2/4/15 9:42 AM, Greg Wooledge wrote: > imadev:~$ unset a; declare -A a; a=(["@"]=foo [!]=bar); declare -p a > declare -A a='([@]="foo" ["!"]="bar" )' > > imadev:~$ unset a; declare -A a='([@]="foo" ["!"]="bar" )' > bash: [@]="foo": invalid associative array key > > If the declare -p output is

Re: Unsetting all elements of an associative array

2015-02-04 Thread Chet Ramey
On 2/4/15 10:27 AM, Piotr Grzybowski wrote: > I think you are right, maybe this one should be considered: > > diff --git a/lib/sh/shquote.c b/lib/sh/shquote.c > index fff4f81..de05f27 100644 > --- a/lib/sh/shquote.c > +++ b/lib/sh/shquote.c > @@ -293,7 +293,7 @@ sh_contains_shell_metas (string) >