Bug 427184 - Can't assign a variable to "[x]"
Can't assign a variable to "[x]"
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: bash (Show other bugs)
7
All Linux
low Severity low
: ---
: ---
Assigned To: Tomas Janousek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-01-01 22:55 EST by H.J. Lu
Modified: 2008-01-02 11:49 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-01-02 11:49:40 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description H.J. Lu 2008-01-01 22:55:53 EST
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-01 23:18:47 EST
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-01 23:19:34 EST
BTW -

[jstanley@rugrat ~]$ a='[x]' ; echo $a
[x]
Comment 3 Tomas Janousek 2008-01-02 04:23:44 EST
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 08:57:13 EST
[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 10:04:28 EST
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 10:12:51 EST
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 10:24:23 EST
See the Pathname Expansion section of the manpage.
Comment 8 H.J. Lu 2008-01-02 11:49:40 EST
OK, I will live with it.

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