Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subs/Functions in C shell?

Status
Not open for further replies.

stackdump

Technical User
Sep 21, 2004
278
0
0
GB
Does csh support subs/functions within the script? I don't want to write subs in separate files for the application I'm working on. So something like;

Function MySub(args)
# do stuff
End Function

and then;

MySub(MyArg)
 
I have found out that aliases can be defined, so I can do the code below. The problem I have now is that some ARGS may not exist, any ideas how I can do this?;

alias Setup ' \
if ($?ARG1) then \
if ($?ARG2) echo "Using" ARG1 \
setenv ARG3 ARG1 \
else \
if ($?ARG2) echo "Default" \
setenv ARG3 ARG4 \
endif \
set path = ( ARG5 ) \
'

Setup ARG1 ARG2 ARG3 ARG4 ARG5
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top