[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: More fun with IFS
From: |
Thorsten Glaser |
Subject: |
Re: More fun with IFS |
Date: |
Wed, 27 Feb 2013 13:31:58 +0000 (UTC) |
Dan Douglas dixit:
>of any reason it should be inserting a '':'' between the two arguments,
>especially for the ''$@'' variants, either quoted or unquoted. It certainly
>can't be because of a word splitting step.
‘:’ is ${IFS::1} and inserted because of the word *concatenation*
(not splitting) that occurs when assigning a vector to a scalar.
>Most script writers treat assignments as identical whether quoted or not.
We had a discussion about that on the Austin ML (when I still
managed to somewhat follow it) and specifically changed it so
shells MUST distinguish between unquoted and quoted $*/$@.
> $ mksh -c 'set one:::two three:::four; IFS=:; cat <<<$@'
>one:::two:three:::four
> $ mksh -c 'set one:::two three:::four; IFS=:; cat <<<"$@"'
>one:::two:three:::four
I think that is completely reasonable and correct here.
>I tend to think AT&T ksh is doing the most reasonable thing here by making the
>concatenated result exactly the same as if expanded as arguments in a quoted
>context, with whitespace separating them.
Why whitespace? $IFS certainly contains none. And the usual
insertion rules all specify the first character of $IFS and
specify what to do if $IFS is empty or unset (which it isn’t
in these examples).
>> In other words, “don’t do that then” (rely on this behaviour).
>
>I wouldn't bother with this language if the only non-random behavior was that
>specified by POSIX. "POSIX doesn't specify it" is a horrible reason to do
>anything.
Right, “POSIX says so” oftentimes also is, after all…
which is why I tried above to argue without it.
>> I think eval is evil anyway ;-)
>
>Eval is frowned upon because it almost always misused. Until shells add first-
>class closures and higher-order functions I'll continue using it.
Yeah, of course, it’s the only way to do some things… I personally
usually abstract everything eval into little functions of their
own and then just use those.
bye,
//mirabilos
--
„nein: BerliOS und Sourceforge sind Plattformen für Projekte, github ist
eine Plattform für Einzelkämpfer“
-- dieses Zitat ist ein Beweis dafür, daß auch ein blindes Huhn
mal ein Korn findet, bzw. – in diesem Fall – Recht haben kann