[Top][All Lists]

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

Re: unsetting associative array executes commands

From: Greg Wooledge
Subject: Re: unsetting associative array executes commands
Date: Thu, 11 Mar 2021 11:49:03 -0500

On Thu, Mar 11, 2021 at 09:38:37AM -0700, Jason A. Donenfeld wrote:
> Single quotes with the nested double quote? That's nuts. But okay. I
> guess there really is some double expansion eval-like logic happening
> with the unset operator.

I removed the double quotes, as they serve no purpose there.

For an indexed array, use:      unset 'a[i]'
For an associative array, use:  unset 'a[$i]'

In both cases, use single quotes, and all will be well.

(In the indexed array case, there is another pitfall involving code
injection in the arithmetic context, so only use sanitized index values.)

reply via email to

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