bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quotes inserted into command


From: Chet Ramey
Subject: Re: Quotes inserted into command
Date: Tue, 22 May 2007 17:53:34 -0400
User-agent: Thunderbird 2.0.0.0 (Macintosh/20070326)

Matt Kane wrote:
> Hello,
> 
> I've got a script that does the following:
> JAVA=/usr/bin/java
> JAVA_W_CLASSPATH="$JAVA -cp \"$classpath\" "
> $JAVA_W_CLASSPATH com.choicestream.foo
> echo $JAVA_W_CLASSPATH
> 
> I've noticed that on different versions of bash, it behaves differently.
> Bash 3.0 will execute:
> /usr/bin/java -cp "/path/to/classes" com.choicestream.foo
> And display the same.
> 
> But Bash 3.1 and 3.2 put single quotes around the double quotes when
> executing.
> /usr/bin/java -cp '"/path/to/classes"' com.choicestream.foo
> But it will display:
> /usr/bin/java -cp "/path/to/classes" com.choicestream.foo
> 
> I don't understand the reason for the discrepancy, and searching for "bash
> quotes" gives me a lot of bash.org nonsense.

I assume you mean the output of `bash -x' or `set -x' when you say "when
executing".  The idea is that the output of bash -x should be reusable as
input.  The bash-3.1 and later output is.  The bash-3.0 output is not,
since the double quotes, which should be a literal part of the command,
are not escaped to prevent them being removed during word expansion.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                       Live Strong.  No day but today.
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]