bug-bash
[Top][All Lists]
Advanced

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

Double quotes do not work in command substitution?


From: Dimitry Golubovsky
Subject: Double quotes do not work in command substitution?
Date: Tue, 3 Jul 2007 09:39:57 -0400

Hi,

Is this behavior considered normal?

address@hidden ~]$ for k in "a b" c ; do echo $k ; done
a b
c
address@hidden ~]$ echo \"a b\" c
"a b" c
address@hidden ~]$ for k in `echo \"a b\" c` ; do echo $k ; done
"a
b"
c
address@hidden ~]$ bash --version
GNU bash, version 3.2.17(1)-release (x86_64-unknown-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
address@hidden ~]$

That is, when a doublequoted string containing whitespace appears
directly on the command line, it is treated  properly ("a b" as one
token). When the same appears as part of command substitution, parts
of the doublequoted string are separated by space it contains, and we
have 3 tokens rather than 2.

If this is normal behavior, how can the desired be achieved, that is,
treat doublequoted strings from command substitution same way as if
they appeared on shell command line?

Thanks.

--
Dimitry Golubovsky

Anywhere on the Web




reply via email to

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