From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <20091004071748.GA16895@nipl.net> References: <20091003191118.GD15021@nipl.net> <45a41ae73e4adf6d1b38fe9c31977c52@proxima.alt.za> <20091004071748.GA16895@nipl.net> Date: Sun, 4 Oct 2009 18:59:59 +0800 Message-ID: <140e7ec30910040359q28c30ea2re5185846042cf43a@mail.gmail.com> From: sqweek To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [9fans] mishandling empty lists - let's fix it Topicbox-Message-UUID: 7d3b4394-ead5-11e9-9d60-3106f5b1d025 2009/10/4 Sam Watkins : > I wrote: >> I don't see how this can be fixed in unix without breaking umpteen milli= on >> shell scripts. > > On Sun, Oct 04, 2009 at 06:12:15AM +0200, lucio@proxima.alt.za wrote: >> By creating new commands with distinct new names. > > I thought of a better way. =C2=A0We can fix the commands without breaking > compatibility, using `--'. =C2=A0`--' in unix normally excludes further o= ptions. It seems to me the obvious way to gain consistency is to do the list parsing in one place only: fn apply { cmd=3D$1 shift while(! test $1 =3D :) { cmd=3D($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