BladeSystem Forums Have Moved here
To make BladeSystem information easier to find, we have moved the BladeSystem forums here, to Servers and Operating Systems.
Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

csh terra incognita

Honored Contributor

csh terra incognita


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?

Madness, thy name is system administration
Honored Contributor

Re: csh terra incognita

Strange, revisiting my O'Reilly reference on the csh I read that in csh aliases (or should be alii, to stay Latin-proof?) could reference command line arguments.
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.
Madness, thy name is system administration
Honored Contributor

Re: csh terra incognita


If you can do it

will have it

Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Honored Contributor

Re: csh terra incognita

Not quite,
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 \!^'
% alias
ping /usr/sbin/ping !$ -n !^
% ping 3 localhost
PING localhost: 64 byte packets
64 bytes from icmp_seq=0. time=0. ms
64 bytes from icmp_seq=1. time=0. ms
64 bytes from icmp_seq=2. time=0. ms

----localhost PING Statistics----
3 packets transmitted, 3 packets received, 0% packet loss
Madness, thy name is system administration