bash-3.2-9.fc7 won't assign a variable to "[x]": [hjl@gnu-6 gsse-tests]$ a="[t]"; echo $a [t] [hjl@gnu-6 gsse-tests]$ a="[x]"; echo $a x [hjl@gnu-6 gsse-tests]$ a="[y]"; echo $a [y]
I'm surprised any of that worked. You need to use single quotes, not double, when using shell special characters as values to a variable. Or am I missing something here?
BTW - [jstanley@rugrat ~]$ a='[x]' ; echo $a [x]
Yeah, Jon is right. [tomi@notes tmp]$ a="[x]"; echo $a [x] [tomi@notes tmp]$ touch x [tomi@notes tmp]$ a="[x]"; echo $a x notabug?
[hjl@gnu-6 gsse-tests]$ which foox /usr/bin/which: no foox in (/usr/kerberos/bin:/export/home/hjl/bin:/sbin:/usr/sbin:/usr/local/bin:/bin:/usr/bin:/export/home/hjl/bin) [hjl@gnu-6 gsse-tests]$ ls -l foox ls: cannot access foox: No such file or directory [hjl@gnu-6 gsse-tests]$ a='[foox]'; echo $a x [hjl@gnu-6 gsse-tests]$ ls -l x -rwxr-xr-x 1 hjl hjl 82 2008-01-01 19:24 x [hjl@gnu-6 gsse-tests]$ a='[foox]'; echo $a [foox] [hjl@gnu-6 gsse-tests]$ touch x [hjl@gnu-6 gsse-tests]$ a='[foox]'; echo $a x [hjl@gnu-6 gsse-tests]$ a="[foox]"; echo $a x [hjl@gnu-6 gsse-tests]$ zsh gnu-6:pts/43[1]> a="[foox]"; echo $a [foox] gnu-6:pts/43[2]> a='[foox]'; echo $a [foox] It looks like I can't have x in my current directory. Otherwise, none of "[XXXXXx]" or '[XXXXXx]' will work.
Oh, seems like it's getting expanded somewhere else, in "echo $a". Try a="[foox]"; echo "$a"
a="[foox]"; echo "$a" works. But it doesn't make any senses since there is no foox anywhere on my machine.
See the Pathname Expansion section of the manpage.
OK, I will live with it.