delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/02/14/18:03:06

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Mon, 14 Feb 2005 18:02:51 -0500 (EST)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Arthur I Schwarz <Arthur_I_Schwarz AT raytheon DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: Bash error in quote handling
In-Reply-To: <OFCED25DDD.7A340E7E-ON88256FA8.0078F1A0-88256FA8.0078FF99@mck.us.ray.com>
Message-ID: <Pine.GSO.4.61.0502141708490.24034@slinky.cs.nyu.edu>
References: <OFCED25DDD DOT 7A340E7E-ON88256FA8 DOT 0078F1A0-88256FA8 DOT 0078FF99 AT mck DOT us DOT ray DOT com>
MIME-Version: 1.0

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 AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019