help with csh alias
Chris Torek
chris at mimsy.UUCP
Wed Apr 12 14:51:24 AEST 1989
In article <8077 at boulder.Colorado.EDU> cdash at boulder.Colorado.EDU
(Charles Shub) writes:
>desired version
> mycommand `expr <nocolon> - 5` other args
This is easy in sh, harder in csh; in csh it must be done in two
steps. What you want is
echo $1 | sed s/://
spliced in for <nocolon>; the natural way to express this would be
expr `echo $1 | sed s/://` - 5
and so the natural way to express the whole thing would be
mycommand `expr \`echo $1 | sed s/://\` - 5` morestuff
This works properly in sh, but not csh. So we have to resort to
shell variables:
set tmp=`echo $1 | sed s/://`; mycommand `expr $tmp - 5` morestuff
or two levels of alias:
alias part1 'expr `echo $1 | sed s/://` - 5'
mycommand `part1` morestuff
or anything equivalent to this, as long as it does it `one splice
at a time'.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.unix.questions
mailing list