Re: chmod -R +x for directories only



"Chris F.A. Johnson" <cfajohnson@xxxxxxxxx> writes:

[...]

> Yes, it creates an array:
>
> $ a=("a b c" b c)
> $ printf "%s\n" "${a[@]}"
> a b c
> b
> c

Yes, my fault. I was confused because

$ echo $a
a b c

But in bash if I want all the elements, it appears I need to use
${a[*]}. But that expands a bit literally:

$ for i in ${a[*]}; do echo $i; done
a
b
c
d
e

So I need to use

$ for i in "${a[@]}"; do echo $i; done
a b c
d
e

I guess all this is consistent with the hacks one has to use with
POSIX shells ("$@" and the like). Personally I think the zsh people
have done the right thing: introduced minor incompatibility for (IMHO)
more sane behaviour. In zsh:

$ a=("a b c" d e)
$ echo $#a
3
$ for i in $a; echo $i
a b c
d
e
$ for i in $=a; echo $i
a
b
c
d
e

However, each to their own.

[...]

.



Relevant Pages