Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Q: Can we force a different shell interpreter for scripts



I could not (did I overlook?) find an answer in the faq
nor the manual.  Any advice is appreciated.  What follows
is an explanation of why I need the answer:

I like zsh and it is my default shell.  But the unix
environment I am working in uses ksh and all my colleagues
are satisfied with that and don't want to change.  Many
tools in the form of shell scripts have been developed over 
the years -- and all these scripts are ksh scripts.  No one
bothered to specify something like "#!ksh" in the first 
line of all these scripts because ksh automatically uses
ksh to interpret scripts (zsh uses ONLY sh unless there is
an interpreter specified in the first line of the script).  

Now when I call one of these scripts from my zsh, zsh 
interprets the script as a Bourne shell and more often than
not the script breaks because it contains a ksh command not
understood by the Bourne shell.  To workaround that, I must
type "ksh command" instead of just "command".  For some of
the more frequently used "command", I make an alias for
"ksh command".  But there are hundreds of such commands; I
get tired of making aliases.  Besides, I do not have a 
complete list of which commands need the "ksh" prefix.

But the most difficult situation is that some of the old,
established ksh scripts in our environment are invoked by
sourcing them in the current working shell, like ". command".
Issuing the same ". command" from my zsh does not work
because such a command usually invokes 10, 20 other ksh 
scripts, and each one will break the script when run in zsh.
The first solution I thought of was to make a local copy of
these scripts and modify them to run in my zsh, such as adding 
"ksh" in front of all the commands invoked.  Then I discover
that some of the scripts have more than 200O lines of code,
and I gave up.  Besides, many of these scripts are still being 
actively maintained (because of changes in the working 
environment, like new files, or new directories being added from
time to time) and very often changes are made without 
public announcements.

My problem will be solved if there is an option in zsh, say
SCRIPT_SHELL=ksh, which I can set so that all scripts invoked
in that zsh are interpreted by ksh (or may be zsh) instead of 
by zh.  But I cannot find such an option.  Is there another
workaround?

mk kwong
Lucent Technologies




Messages sorted by: Reverse Date, Date, Thread, Author