12-01-2004 09:13 PM
this is a bit daft.
A user asked me if he could define an alias so that he could pass parameters.
I replied that to achieve this he would have to define a shell function.
To show him how easily this would be done I defined one that fullfilled his needs in a Bourne shell.
Then I found out that this user's login shell was a C shell, and I told him that he would have to place his definition in $HOME/.login or $HOME/.cshrc.
What followed was a bit of an embarrassement since I'm not into csh compatibles at all.
I was pretty bemused to not have found any reference to function definitions in the manpage of csh, nor in my O'Reilly Unix in a Nutshell desktop reference.
I cannot believe that csh doesn't have a notion of functions.
Can this really be, or have I overlooked it?
12-01-2004 09:39 PM
If that's the case I can see that there is a lesser urge for functions in csh unlike the bourne compatibles.
But grouping reusable code blocks in functions still seems cleaner to me.
12-02-2004 12:26 AM
also the csh-like references at shelldorado
aren't overly expressive as far as the existence of user defined functions are concerned.
However, for the task given the csh sort of aliasing is quite sufficient.
It was merely something trivial as processing of args.
% alias ping '/usr/sbin/ping \!$ -n \!^'
ping /usr/sbin/ping !$ -n !^
% ping 3 localhost
PING localhost: 64 byte packets
64 bytes from 127.0.0.1: icmp_seq=0. time=0. ms
64 bytes from 127.0.0.1: icmp_seq=1. time=0. ms
64 bytes from 127.0.0.1: icmp_seq=2. time=0. ms
----localhost PING Statistics----
3 packets transmitted, 3 packets received, 0% packet loss