[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Changing the way bash expands associative array subscripts
From: |
Alex fxmbsw7 Ratchev |
Subject: |
Re: Changing the way bash expands associative array subscripts |
Date: |
Tue, 16 Mar 2021 13:26:30 +0100 |
no idea about your internal rules of keyword and builtin but clearly its
gotta parse it at most 1. level otherwise its big security fault isnt it
its a shell fuctionality keyword, unset, so ..
On Tue, Mar 16, 2021 at 1:21 PM Greg Wooledge <greg@wooledge.org> wrote:
> On Tue, Mar 16, 2021 at 09:24:01AM +0100, Alex fxmbsw7 Ratchev wrote:
> > it doesnt make me much sense that unset -v assoc[$key] gives syntax error
> > or so..
>
> Think of it this way: what would happen if you had a filename in a
> variable -- say, $file -- and you ran this command:
>
> rm -f $file
>
> You'd expect that to fail, right? Of course.
>
> unset -v assoc[$key] fails for exactly the same reason. unset does not
> have any magical powers. It's only a shell builtin, NOT a shell keyword.
> Therefore, the standard shell rules apply. Expansions occur first,
> followed by word splitting, which cause a list of argument words to be
> created and passed as arguments to the builtin.
>
> key='two words'
> unset -v assoc[$key]
>
> ==> 'unset' '-v' 'assoc[two' 'words]'
>
> You can even use set -x to see this in action:
>
> unicorn:~$ key='two words'
> unicorn:~$ set -x
> unicorn:~$ unset -v assoc[$key]
> + unset -v 'assoc[two' 'words]'
> bash: unset: `assoc[two': not a valid identifier
> bash: unset: `words]': not a valid identifier
>
>
- Changing the way bash expands associative array subscripts, Chet Ramey, 2021/03/15
- Re: Changing the way bash expands associative array subscripts, Léa Gris, 2021/03/15
- Re: Changing the way bash expands associative array subscripts, Lawrence Velázquez, 2021/03/16
- Re: Changing the way bash expands associative array subscripts, Alex fxmbsw7 Ratchev, 2021/03/16
- Re: Changing the way bash expands associative array subscripts, Greg Wooledge, 2021/03/16
- Re: Changing the way bash expands associative array subscripts,
Alex fxmbsw7 Ratchev <=
- Re: Changing the way bash expands associative array subscripts, Greg Wooledge, 2021/03/16
- Re: Changing the way bash expands associative array subscripts, Alex fxmbsw7 Ratchev, 2021/03/16
- Re: Changing the way bash expands associative array subscripts, Alex fxmbsw7 Ratchev, 2021/03/16
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/03/29
- Re: Changing the way bash expands associative array subscripts, Robert Elz, 2021/03/16
- Re: Changing the way bash expands associative array subscripts, Alex fxmbsw7 Ratchev, 2021/03/17
- Re: Changing the way bash expands associative array subscripts, Robert Elz, 2021/03/17
Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/03/29
Re: Changing the way bash expands associative array subscripts, Koichi Murase, 2021/03/15