[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: inconsistent field splitting
From: |
Pierre Gaston |
Subject: |
Re: inconsistent field splitting |
Date: |
Wed, 18 Aug 2010 12:45:54 +0300 |
On Wed, Aug 18, 2010 at 12:36 PM, Marc Herbert <Marc.Herbert@gmail.com> 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 is difficult enough; why is such an inconsistency making
> it even more confusing?
>
> Uwe Waldmann might give a clue in his excellent "Guide to Unix shell
> quoting":
>
> Note that in these [assignment + others] cases, the shell syntax
> allows only a single word, not a sequence of words, so that blank
> interpretation or expansion of globbing characters might result in
> something syntactically illegal.
>
> In other words:
>
> In order to save you from some very obvious syntax errors, I'll
> make quoting even more confusing than it already is.
>
> Sorry but I am not grateful at all.
>
> Or is there a better rationale for this design?
>
What should a=* or a=$(echo 1 2) do?
Assign only the first file or just 1 to a? or result in an error?
This hardly seem more consistent or less surprising to me.
There are other places where word splitting is disabled, in case,
inside [[ ]]...etc...
- inconsistent field splitting, Marc Herbert, 2010/08/18
- Re: inconsistent field splitting, Andreas Schwab, 2010/08/18
- Re: inconsistent field splitting,
Pierre Gaston <=
- Re: inconsistent field splitting, Marc Herbert, 2010/08/18
- Re: inconsistent field splitting, Andreas Schwab, 2010/08/18
- Re: inconsistent field splitting, Marc Herbert, 2010/08/18
- Re: inconsistent field splitting, Andreas Schwab, 2010/08/18
- Re: inconsistent field splitting, Greg Wooledge, 2010/08/18
- Re: inconsistent field splitting, lxnf98mm, 2010/08/20
- Re: inconsistent field splitting, Eric Blake, 2010/08/20
- Re: inconsistent field splitting, Marc Herbert, 2010/08/20
- Re: inconsistent field splitting, Marc Herbert, 2010/08/19