Article View: comp.unix.shell
Article #1613Re: Multiline aliases in csh ?
From: Joe Wells
Date: Thu, 25 Oct 1990 08:58
Date: Thu, 25 Oct 1990 08:58
34 lines
1482 bytes
1482 bytes
aps@tut.fi (Suntioinen Ari) writes:
Is there any way to define multi line alias in csh ?
What I mean is (for example) if-else or foreach loop
as a part of alias.
Sure, here's an appropriately twisted example:
alias which '(set argv=($path) target=\!*; whichi)'
alias whichi 'if (! $#argv) set status=1 && whichii'
alias whichii \
'if (-x "$1/$target") set status=1 && shift && eval "whichi" \\
|| if ($#argv > 0) echo "$1/$target"'
Conditionals are done with:
if (condition) set status=1 && else-statement || then-statement
Looping is done with recursion, which requires you to use "eval",
otherwise the csh will detect the recursion and refuse to do it.
Note, the last line should actually read:
|| echo "$1/$target"'
but yet another csh bug prevents it from working that way.
Enjoy,
--
Joe Wells <jbw@bu.edu>
PS. I think this example clearly justifies why the author(s) of the csh
will be roasting in hell for a long long long time.
Technical Details
Message-ID:
<JBW.90Oct25045850@bucsf.bu.edu>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!samsung!xylogics!bu.edu!nntp-read!jbwReferences:
<APS.90Oct23053623@kaarne.tut.fi>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!samsung!xylogics!bu.edu!nntp-read!jbw From: jbw@bucsf.bu.edu (Joe Wells) Newsgroups: comp.unix.shell Subject: Re: Multiline aliases in csh ? Message-ID: <JBW.90Oct25045850@bucsf.bu.edu> Date: 25 Oct 90 08:58:50 GMT References: <APS.90Oct23053623@kaarne.tut.fi> Sender: news@bu.edu.bu.edu Organization: Boston University Computer Science Department Lines: 34 In-reply-to: aps@tut.fi's message of 23 Oct 90 04:36:23 GMT