Re: misleading error message from variable modifier

2018-03-17 Thread don fong
Chet, thanks for the tip about where to find the tests for subst.c . i still think that my tests cover some cases that aren't covered by posixexp.tests . it's cool that you increased the coverage of subst.c . how did you produce the report? i didn't see a script or makefile target to do it.

Re: question on retrieving map(-A) value w/indirect name

2018-03-17 Thread L A Walsh
David Margerison wrote: processSrvState() { local cur_up="$1[cur_up]" local max_up="$1[max_up]" if [[ "${!cur_up}" == "${!max_up}" ]] ; then echo ok fi } declare -A foo=([cur_up]=11 [max_up]=11) processSrvState foo # note that the array name must not conflict with any keys

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-17 Thread Clark Wang
On Sun, Mar 18, 2018 at 1:18 AM, Chet Ramey wrote: > On 3/17/18 12:16 AM, Clark Wang wrote: > > On Sat, Mar 17, 2018 at 1:00 AM, wrote: > > > >> > >> It works correctly if the single quote is itself quoted. Our test > wordlist > >> would then be:

Re: misleading error message from variable modifier

2018-03-17 Thread Chet Ramey
On 3/17/18 6:39 PM, don fong wrote: > Chet, thanks for the tip about where to find the tests for subst.c .  i > still think that my tests cover some cases that aren't covered by > posixexp.tests . There are other test cases. > it's cool that you increased the coverage of subst.c .  how did you

Re: misleading error message from variable modifier

2018-03-17 Thread don fong
will the coverage target be in an upcoming release? On Sat, Mar 17, 2018 at 7:13 PM, Chet Ramey wrote: > On 3/17/18 6:39 PM, don fong wrote: > > Chet, thanks for the tip about where to find the tests for subst.c . i > > still think that my tests cover some cases that

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-17 Thread Paulo Marcel Coelho Aragão
On Sat, Mar 17, 2018 at 2:06 PM, Chet Ramey wrote: > Processing the word argument to -W honors shell quoting, in order to > provide a simple way to return words containing shell metacharacters and > characters in $IFS. There is a sentence to this effect in the texinfo >

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-17 Thread Clark Wang
On Sat, Mar 17, 2018 at 7:32 PM, Paulo Marcel Coelho Aragão < marcelpa...@gmail.com> wrote: > > Actually every word in the -W "wordlist" needs to be sh-quoted twice > (with > > ``printf %q'' or the new ``${var@Q}'' syntax). It'll be a bit easier if > you > > use an array. > > On a second thought,

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-17 Thread Chet Ramey
On 3/16/18 1:00 PM, marcelpa...@gmail.com wrote: > Bash Version: 4.4 > Patch Level: 12 > Release Status: release > > Description: > compgen -W "wordlist" doesn't split wordlist on $IFS if wordlist contains > unquoted single quotes. For instance, this wordlist, "foo'bar aaa bbb", won't > be split

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-17 Thread Chet Ramey
On 3/17/18 12:16 AM, Clark Wang wrote: > On Sat, Mar 17, 2018 at 1:00 AM, wrote: > >> >> It works correctly if the single quote is itself quoted. Our test wordlist >> would then be: "foo\'bar aaa bbb" >> >> paulo@monk:~/tmp$ compgen -W "foo\'bar aaa bbb" -- a >> aaa >>

Re: question on retrieving map(-A) value w/indirect name

2018-03-17 Thread L A Walsh
Chet Ramey wrote: On 3/16/18 8:50 PM, L A Walsh wrote: I'm a bit confused ... If I have assoc-array: declare -A foo=([one]=11 [two]=22) and am passing name in another var, like "fee" fee=foo I tried echoing the val: echo ${!fee[one]} but got nothing -- tried a few other syntaxes.

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-17 Thread Paulo Marcel Coelho Aragão
On Sat, Mar 17, 2018 at 12:16:24PM +0800, Clark Wang wrote: > This seems to work but it does not. For example in the command line > > # some-cmd f > > will become > > # some-cmd foo'bar > > then you press ENTER and it'll still wait for another ' char. Oh, I hadn't realized that, you're

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-17 Thread Paulo Marcel Coelho Aragão
> Actually every word in the -W "wordlist" needs to be sh-quoted twice (with > ``printf %q'' or the new ``${var@Q}'' syntax). It'll be a bit easier if you > use an array. On a second thought, sh-quoting twice with ${var@Q} won't work as expected in this case, since it encloses the expanded value

Re: question on retrieving map(-A) value w/indirect name

2018-03-17 Thread David Margerison
On 17 March 2018 at 20:40, L A Walsh wrote: > > I seebut that begs the question, how do you access an array's > members using a var holding the array's name? > > I wanted to be able to do something like have a set of > values in an assoc. map, and pass the name to a generic >

Re: question on retrieving map(-A) value w/indirect name

2018-03-17 Thread David Margerison
On 17 March 2018 at 11:50, L A Walsh wrote: > > I'm a bit confused ... > If I have assoc-array: > > declare -A foo=([one]=11 [two]=22) > > and am passing name in another var, like "fee" > > fee=foo > > I tried echoing the val: > > echo ${!fee[one]} > > but got nothing -- tried