Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Command substitution reduce spaces even in strings

0 views
Skip to first unread message

ma...@fiz15.jupiter.vein.hu

unread,
Dec 8, 2009, 8:01:23 AM12/8/09
to bug-...@gnu.org
Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: i686-pc-linux-gnu-gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' -DSTANDARD_UTILS_PATH='/bin:/usr/bin:/sbin:/usr/sbin' -DSYS_BASHRC='/etc/bash/bashrc' -DSYS_BASH_LOGOUT='/etc/bash/bash_logout' -DNON_INTERACTIVE_LOGIN_SHELLS -DSSH_SOURCE_BASHRC -O2 -march=athlon-mp -pipe
uname output: Linux fiz15.jupiter.vein.hu 2.6.30-gentoo-r8 #1 SMP Thu Nov 12 16:15:30 CET 2009 i686 AMD Athlon(tm) MP 2000+ AuthenticAMD GNU/Linux
Machine Type: i686-pc-linux-gnu

Bash Version: 4.0
Patch Level: 35
Release Status: release

Description:
[Detailed description of the problem, suggestion, or complaint.]

The command substitution reduce spaces even in strings.
This is not healthy on copying files of which names containing double or
more spaces generated by command substitution.
Short example:

$ echo $(echo "'alfa beta'")
'alfa beta'

Instead of 'alfa beta' with double space.

Repeat-By:
[Describe the sequence of events that causes the problem
to occur.]


$ echo $(echo "'alfa beta'")
'alfa beta'

Instead of 'alfa beta' with double space.


Greg Wooledge

unread,
Dec 8, 2009, 3:05:59 PM12/8/09
to ma...@fiz15.jupiter.vein.hu, bug-...@gnu.org

Matias A. Fonzo

unread,
Dec 8, 2009, 1:58:10 PM12/8/09
to bug-...@gnu.org
On Tue, 08 Dec 2009 14:01:23 +0100
ma...@fiz15.jupiter.vein.hu wrote:

> Configuration Information [Automatically generated, do not change]:
> Machine: i686
> OS: linux-gnu
> Compiler: i686-pc-linux-gnu-gcc
> Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' -DSTANDARD_UTILS_PATH='/bin:/usr/bin:/sbin:/usr/sbin' -DSYS_BASHRC='/etc/bash/bashrc' -DSYS_BASH_LOGOUT='/etc/bash/bash_logout' -DNON_INTERACTIVE_LOGIN_SHELLS -DSSH_SOURCE_BASHRC -O2 -march=athlon-mp -pipe
> uname output: Linux fiz15.jupiter.vein.hu 2.6.30-gentoo-r8 #1 SMP Thu Nov 12 16:15:30 CET 2009 i686 AMD Athlon(tm) MP 2000+ AuthenticAMD GNU/Linux
> Machine Type: i686-pc-linux-gnu
>
> Bash Version: 4.0
> Patch Level: 35
> Release Status: release
>
> Description:
> [Detailed description of the problem, suggestion, or complaint.]
>
> The command substitution reduce spaces even in strings.
> This is not healthy on copying files of which names containing double or
> more spaces generated by command substitution.
> Short example:
>

> $ echo $(echo "'alfa beta'")
> 'alfa beta'
>
> Instead of 'alfa beta' with double space.
>

> Repeat-By:
> [Describe the sequence of events that causes the problem
> to occur.]
>
>

> $ echo $(echo "'alfa beta'")
> 'alfa beta'
>
> Instead of 'alfa beta' with double space.
>
>

Hello all.

Use more quotes, like:

echo "$(echo "'alfa beta'")"

Regards,
Matias


Ken Irving

unread,
Dec 8, 2009, 3:02:17 PM12/8/09
to bug-...@gnu.org

--
Ken Irving, ken.i...@alaska.edu


Marc Herbert

unread,
Dec 9, 2009, 4:10:26 AM12/9/09
to bug-...@gnu.org
ma...@fiz15.jupiter.vein.hu a écrit :
> Short example:

> $ echo $(echo "'alfa beta'")
> 'alfa beta'
>
> Instead of 'alfa beta' with double space.

Always try tracing to understand what is going on:

echo $(set -x ;echo "'alfa beta'")

++ echo ''\''alfa beta'\'''


http://www.mpi-inf.mpg.de/~uwe/lehre/unixffb/quoting-guide.html

0 new messages