Bash expansion question

Hans Fugal hans at fugal.net
Wed Feb 18 13:16:34 MST 2009


Chris wrote:
> Dear bash experts,
> 
> Observe:
> 
> bash$ echo $(echo "1:2")
> 1:2
> 
> bash$ echo $(echo "1,2")
> 1 2
> 
> There's no comma in the output of the second command; it's been
> replaced by a space.
> 
> Which shell expansion mechanism replaces the comma with a space?
> 
> It looks kind of like brace expansion, but there are no braces.
> 
> The man page description of command-substitution mentions only
> post-substitution word-splitting, but that depends on IFS (which in my
> case is unset), so I presume the comma is not being used as a
> potential word separator.
> 

Works for me


$ echo $(echo "1:2")
1:2
$ echo $(echo "1,2")
1,2
$ bash --version
GNU bash, version 3.2.17(1)-release (i386-apple-darwin9.0)
Copyright (C) 2005 Free Software Foundation, Inc.

also

$ echo $(echo "1,2")
1,2
$ bash --version
GNU bash, version 3.1.17(1)-release (i486-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.


-- 
Hans Fugal ; http://hans.fugal.net

There's nothing remarkable about it. All one has to do is hit the
right keys at the right time and the instrument plays itself.
    -- Johann Sebastian Bach



More information about the PLUG mailing list