2009/10/4 Sam Watkins <[email protected]>:
> I wrote:
>> I don't see how this can be fixed in unix without breaking umpteen million
>> shell scripts.
>
> On Sun, Oct 04, 2009 at 06:12:15AM +0200, [email protected] wrote:
>> By creating new commands with distinct new names.
>
> I thought of a better way. We can fix the commands without breaking
> compatibility, using `--'. `--' in unix normally excludes further options.
It seems to me the obvious way to gain consistency is to do the list
parsing in one place only:
fn apply {
cmd=$1
shift
while(! test $1 = :) {
cmd=($cmd $1)
shift
}
for(i in $*) $cmd <$i
}
# eg: apply grep foo : *.c
Of course, this is likely to run you into other problems with the way
some programs want to use their arguments, which is why unix/plan 9
adopt the pragmatic approach.
PS. excuse the test usage, feel free to point out the ~ idioms - if I
see them often enough they might stick in my memory :)
PPS. i didn't actually check the semantics of for on an empty list,
maybe a conditional is required
-sqweek