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 :)