Want sh -> csh translator (and vice-versa)

lcc.gm at UCLA-LOCUS.ARPA lcc.gm at UCLA-LOCUS.ARPA
Fri May 11 07:24:24 AEST 1984


From:            Greg McGary <lcc.gm at UCLA-LOCUS.ARPA>


>>	Anyone out there have a Bourne-shell-script to C-shell-script
>>	translator?  I'm converting some sh scripts to csh and finding
>>	the process tediously mechanical.
>>
>>	The reverse procedure would be nice, too, but I'm more concerned with
>>	the sh -> csh direction right now.

My experience has been that csh(1) is practically useless for writing
bullet-proofed, production shell programs.  I think that csh wins
hands-down as an *interactive* command interpreter because of history,
aliases, and hashed command lookup; however, sh leaves csh in the dust
when it comes to shell programming.  Sh parses control constructs
before executing them and allows redirection of output to and from them,
and it handles signals in an intelligent and flexible manner.  Csh treats
control constructs as reserved commands and attempts to figure out what
to do on the fly, and it has a very simple minded way of treating signals.
Sh also starts up a heck of a lot faster than csh.

I like to think of my login csh as the ``mother ship'' (and it really
is a mother at times!) and my collection of sh programs as ``fighters''
that I can deploy to get something done.  (Humor me, I've been here
all night....)

Don't let the ALGOL style syntax put you off, sh is a tremendously
useful tool.  For an excellent tutorial on writing programs in sh, pick
up a copy of Kernighan and Pike's latest ``The Unix Programming
Environment''.

Avoid mechanical tedium today!
Leave your bourne shell scripts as bourne shell scripts!

--Greg--

PS:

Sorry I didn't answer your query directly.  Forgive me if you have
already considered the merits of the two shells and have decided that
you want to convert them anyway.  If such is the case, I don't know of
any translators.  Personally, I usually choose to rewrite csh programs
into sh by hand, since most csh beasties that must be rewritten are
very poorly designed to begin with, so the task becomes re-design and
re-implementation, rather than simply translation.



More information about the Comp.unix mailing list