On Mon, Sep 19, 2011 at 04:18:18PM +0300, Philip Ganchev wrote:
> On Mon, Sep 19, 2011 at 1:47 AM, Robert Shinka <k...@unknownlayer.net> wrote:
> > On Sun, Sep 18, 2011 at 09:20:21PM +0200, Jan Kanis wrote:
> 
> >>  Bash treats command substitution and variable expansion as a list of
> >>  whitespace separated tokens. It also includes escapes to treat both as a
> >>  single token, in case you don't want the default behaviour.
> >>
> >>  Fish does the same for variables, except it doesn't split the contents 
> >> when
> >>  the variable is used, but it stores the tokens in a structured way as an
> >>  array. Command substitution works a bit differently. Maintaining a 
> >> structured
> >>  form of data like with variables isn't possible because it is output from
> >>  arbitrary commands, so fish splits the command output like bash does, but 
> >> only
> >>  on newlines. However fish doesn't provide a way to prevent the splitting.
> >
> > If fish reconstructed "$var" the same way it split it (with \n), then
> > your problem wouldn't exist. You could work with lines as usual with
> > $var, and "$var" would produce the exact data it was created with.
> > If anyone needed a space-separated version of the string for whatever
> > reason, they could trivially do so with echo or tr, but I think that's a
> > rare case. Right now, there's no reasonable utility.
> 
> Yes, that would be more logical. But separating with spaces saves
> screen space when printing the array, which is quite a common
> operation.

I'm only proposing changing the semantics of "$var", while $var would be
unchanged, so the common case of (echo $var) would format as usual,
separated with spaces, but (echo "$var") would print the original
string, including any embedded newlines.

eg.,
> set var (echo 1\n2\n3)
> echo $var     # echo '1' '2' '3'
1 2 3
> echo "$var"   # echo '1\n2\n3'
1
2
3

Is there a compelling reason not to make this change?

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
Learn about the latest advances in developing for the 
BlackBerry&reg; mobile platform with sessions, labs & more.
See new tools and technologies. Register for BlackBerry&reg; DevCon today!
http://p.sf.net/sfu/rim-devcon-copy1 
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to