Re: inconsistent field splitting

2010-08-20 Thread Marc Herbert
>> There is a big difference between >> >> $ a=";" >> >> and >> >> $ a=; > And for the VERY ignorant what is the difference In the second case the unescaped semi-colon is a separator totally unrelated to the assignment, which has no value at all. The variable is assigned an empty string.

Re: inconsistent field splitting

2010-08-20 Thread Eric Blake
On 08/20/2010 07:12 AM, lxnf9...@comcast.net wrote: >> There is a big difference between >> >> $ a=";" >> >> and >> >> $ a=; >> >> Andreas. >> >> > > And for the VERY ignorant what is the difference a=';' assigns the value ";" to $a. a=; assigns the empty string to a, because the ; is the metach

Re: inconsistent field splitting

2010-08-20 Thread lxnf98mm
On Wed, 18 Aug 2010, Andreas Schwab wrote: Marc Herbert writes: Probably result in some error; I do not really care in this initial stage. In any case it should not perform any *implicit* (and thus confusing) quoting. There is no quoting, the shell just doesn't split into words, which doesn

Re: inconsistent field splitting

2010-08-19 Thread Pierre Gaston
On Thu, Aug 19, 2010 at 12:32 PM, Marc Herbert wrote: > Since inconsistency is basically "not the same rule > everywhere", it typically shows in (good) documentation. Indeed: > >  http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06 >  2.6 Word Expansions >  Not all ex

Re: inconsistent field splitting

2010-08-19 Thread Marc Herbert
Since inconsistency is basically "not the same rule everywhere", it typically shows in (good) documentation. Indeed: http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06 2.6 Word Expansions Not all expansions are performed on every word, as explained in the fo

Re: inconsistent field splitting

2010-08-18 Thread Greg Wooledge
On Wed, Aug 18, 2010 at 12:53:25PM +0100, Marc Herbert wrote: > > Sorry but I am not interested at all in how the current implementation > works. I am only wondering why it was *designed* like this. > > Try to remove your expert hat for one second and take the stance of > some developer new to th

Re: inconsistent field splitting

2010-08-18 Thread Andreas Schwab
Marc Herbert writes: > Sorry but I am not interested at all in how the current implementation > works. I am only wondering why it was *designed* like this. A variable can only contain a single string of characters. There is nothing at all to split. > "Everything makes sense" is a nice feature

Re: inconsistent field splitting

2010-08-18 Thread Marc Herbert
Le 18/08/2010 12:14, Andreas Schwab a écrit : > Marc Herbert writes: >> In any case it should not perform any *implicit* (and >> thus confusing) quoting. > > There is no quoting, the shell just doesn't split into words, I know but it looks like quoting, because quoting is how you prevent word sp

Re: inconsistent field splitting

2010-08-18 Thread Andreas Schwab
Marc Herbert writes: > Probably result in some error; I do not really care in this initial > stage. In any case it should not perform any *implicit* (and > thus confusing) quoting. There is no quoting, the shell just doesn't split into words, which doesn't make any sense in an assignment. > Quo

Re: inconsistent field splitting

2010-08-18 Thread Marc Herbert
> What should a=* or a=$(echo 1 2) do? > Assign only the first file or just 1 to a? or result in an error? Probably result in some error; I do not really care in this initial stage. In any case it should not perform any *implicit* (and thus confusing) quoting. > This hardly seem more consistent

Re: inconsistent field splitting

2010-08-18 Thread Pierre Gaston
On Wed, Aug 18, 2010 at 12:36 PM, Marc Herbert wrote: > Compare: > >   for a in "$(echo 1 2)"; do echo "x${a}x"; done > x1 2x >   for a in  $(echo 1 2) ; do echo "x${a}x"; done > x1x > x2x > >   a="$(echo 1 2)"; echo "x${a}x" > x1 2x >    a=$(echo 1 2);  echo "x${a}x" > x1 2x > > > > Shell quoting

Re: inconsistent field splitting

2010-08-18 Thread Andreas Schwab
Marc Herbert writes: >for a in $(echo 1 2) ; do echo "x${a}x"; done This applies word splitting on the expansion of $(echo 1 2). > a=$(echo 1 2); echo "x${a}x" This doesn't. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5

inconsistent field splitting

2010-08-18 Thread Marc Herbert
Compare: for a in "$(echo 1 2)"; do echo "x${a}x"; done x1 2x for a in $(echo 1 2) ; do echo "x${a}x"; done x1x x2x a="$(echo 1 2)"; echo "x${a}x" x1 2x a=$(echo 1 2); echo "x${a}x" x1 2x Shell quoting is difficult enough; why is such an inconsistency making it even more confusi