[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
inconsistent field splitting
From: |
Marc Herbert |
Subject: |
inconsistent field splitting |
Date: |
Wed, 18 Aug 2010 10:36:36 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.7) Gecko/20100720 Fedora/3.1.1-1.fc13 Thunderbird/3.1.1 |
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?
- inconsistent field splitting,
Marc Herbert <=