I am having a little trouble with function calls in tcsh.
---- START
#!/usr/bin/tcsh
test() {
statement1;
statement2;
}
test
---- END
During runtime I receive the following error...
"Badly placed ()'s."
If you anybody can point me to the right direction would be greatly
appreciated.
- Abdul Bahar
> I am having a little trouble with function calls in tcsh.
There are no shell functions in csh and tcsh.
> If you anybody can point me to the right direction would be greatly
> appreciated.
The right direction is away from csh and tcsh.
< http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ >
< http://www.grymoire.com/Unix/CshTop10.txt >
Try zsh, ksh, or perhaps bash.
--
Göran Larsson http://www.mitt-eget.com
i didn't know only bsh supported it
Not just bsh. Also bash, sh, ksh, and just about every non-csh-derived
shell.
One of the many reasons why csh is a lousy scripting shell. See
<http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/> for more of them.
--
Barry Margolin, bar...@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
- Rajib
The lack of [t]csh functions is the ultimate irony
given that csh was supposed to be C-like. It is
missing what is probably one of the most important
features of C! I personally would not even consider
programming in a language that did have functions
or some similar objects. Would you?
Do you have files lying around that have "#!/bin/csh"
(or somesuch)as the first line? You should seriously
consider changing the first line to "#!/bin/ksh"
(or somesuch) then converting the stuff inside those
files to something maintainable/portable and containing
modular implementation (functions).
C shell has been condemned 8 ways from Sunday, but
to me all it took was the glaring absence of functions.
Interactively it may be fine, but who wants to run
a particular shell as command interpreter (csh)
and program modules in a radically different shell
language? Could this lead to a bad case of pathological
software schizophrenia?
Incidentally, one of my past professional tasks was
to move developers from 'csh' to 'ksh'. They were
all very happy to say goodbye to 'csh'. And many
were csh fanatics. Never saw one that wasn't, come
to think of it. Otherwise they wouldn't be still
using it.
HTH
Tim
> C shell has been condemned 8 ways from Sunday, but
> to me all it took was the glaring absence of functions.
The old Bourne shell didn't have functions either.
We just wrote a separate shell script.
--
Sending unsolicited commercial e-mail to this account incurs a fee of
$500 per message, and acknowledges the legality of this contract.
Good point! I would have done the same
without functions. Amounts to augmenting the UNIX
command set, doesn't it? But the overhead?! Probably
worth it. Wonder if the [t]csh folks use this trick?
I haven't looked at that many [t]csh modules ... my
nausea tolerance is minimal. I knew early Bourne was
functionless but never had the displeasure of bumping
into Bourne that braindead. Wonder when it was Bourne
got them.
Tim
> Wonder if the [t]csh folks use this trick?
That's what I did. You also had to do this if you wanted to pipe the
output into a for/while loop - because csh can't use redirection with
control structures. I developed a soft spot on my head for the C shell
- where I bashed it against the wall during moments like this.
> Wonder when it was Bourne got them [shell functions]
I think AT&T Unix System V?