From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <4AC9D739.5040504@maht0x0r.net> Date: Mon, 5 Oct 2009 12:23:37 +0100 From: matt User-Agent: Mozilla Thunderbird 1.0.6 (X11/20060326) MIME-Version: 1.0 To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> References: <20091003191118.GD15021@nipl.net> <45a41ae73e4adf6d1b38fe9c31977c52@proxima.alt.za> <20091004071748.GA16895@nipl.net> <140e7ec30910040359q28c30ea2re5185846042cf43a@mail.gmail.com> In-Reply-To: <140e7ec30910040359q28c30ea2re5185846042cf43a@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [9fans] mishandling empty lists - let's fix it Topicbox-Message-UUID: 7ea94410-ead5-11e9-9d60-3106f5b1d025 sqweek wrote: > >fn apply { > cmd=$1 > shift > while(! test $1 = :) { > cmd=($cmd $1) > shift > } > for(i in $*) $cmd <$i >} ># eg: apply grep foo : *.c > > > that's the beauty of the rc shell, you can define what you like fn cat { if(~ $#* 0) /bin/cat /dev/null if not { as = () for(a in $*) { if(~ $a -) as = ($as /fd/0) if not as = ($as $a) } /bin/cat $as } } now % echo test | cat % echo test | cat - test % cat /lib/words | sed 1q AAA % If your shell programs are defeated by unexpected empty lists I suggest you write better shell programs :)