This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bash error in quote handling


On Mon, 14 Feb 2005, Arthur I Schwarz wrote:

> I think this is an error?

Huh?  What is?  What exactly are the commands you're trying to run?  What
exactly is the output?  What is wrong with the output?

Let me try to guess (below):

>  a. star="*"; echo $star
>  b. star=*;   echo $star

You're saying that the above commands produce the contents of the
directory, and that this is correct.

>  c. star='*'; echo $star
>  d. star=\*;  echo $star

The above commands produce the contents of the directory, and you think
this is incorrect (should be a literal "*").

>  e. star='\*'; echo $star
>  f. star="\*"; echo $star

The above commands produce the string "\*", and you think it should be
"*".

AFAIK, the above is all expected behavior.

The first four commands (a.-d.) set the variable "star" to the same exact
value, namely, the literal "*".  When the shell sees $star, it expands the
contents of it (which is a "*" wildcard), so you get the contents of the
directory.  The manner of quoting you used when assigning the value of the
variable is irrelevant.

If you want echo to produce a literal "*", use 'echo "$star"' (double
quotes to allow variable substitution but prevent shell expansion).

Frankly, at the moment I can't think of a reason why the last two commands
produce "\*" (it's not a nullglob issue, as I first thought).  I'm
reasonably sure it's also expected, but I'll investigate the actual reason
later.
HTH,
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"The Sun will pass between the Earth and the Moon tonight for a total
Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]