Bug 427184 - Can't assign a variable to "[x]"
Summary: Can't assign a variable to "[x]"
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 7
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Tomas Janousek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-01-02 03:55 UTC by H.J. Lu
Modified: 2008-01-02 16:49 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2008-01-02 16:49:40 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description H.J. Lu 2008-01-02 03:55:53 UTC
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]

Comment 1 Jon Stanley 2008-01-02 04:18:47 UTC
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?

Comment 2 Jon Stanley 2008-01-02 04:19:34 UTC
BTW -

[jstanley@rugrat ~]$ a='[x]' ; echo $a
[x]


Comment 3 Tomas Janousek 2008-01-02 09:23:44 UTC
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?

Comment 4 H.J. Lu 2008-01-02 13:57:13 UTC
[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.


Comment 5 Tomas Janousek 2008-01-02 15:04:28 UTC
Oh, seems like it's getting expanded somewhere else, in "echo $a".
Try a="[foox]"; echo "$a"

Comment 6 H.J. Lu 2008-01-02 15:12:51 UTC
a="[foox]"; echo "$a" works. But it doesn't make any senses since there is
no foox anywhere on my machine.

Comment 7 Tomas Janousek 2008-01-02 15:24:23 UTC
See the Pathname Expansion section of the manpage.

Comment 8 H.J. Lu 2008-01-02 16:49:40 UTC
OK, I will live with it.


Note You need to log in before you can comment on or make changes to this bug.