1753521 Members
4854 Online
108795 Solutions
New Discussion юеВ

Re: csh terra incognita

 
Ralph Grothe
Honored Contributor

csh terra incognita

Hi,

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?

Rgds.
Ralph
Madness, thy name is system administration
3 REPLIES 3
Ralph Grothe
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
Steve Steel
Honored Contributor

Re: csh terra incognita

Hi


If you can do it

www.shelldorado.com

will have it


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Ralph Grothe
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.

e.g.

% alias ping '/usr/sbin/ping \!$ -n \!^'
% alias
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
Madness, thy name is system administration