Wrong Shell Invoking My Script On Linux

I have a shell script that does NOT have the '#!' line at the top. It is written for ksh. The shell in my passwd entry is '/usr/bin/ksh' and my SHELL env variable is '/usr/bin/ksh'. Now, here's the issue. I invoke the script on Solaris with './myprog'. This works fine. I also run the same script on Mandrake 9.0 Linux and Red Hat 7.3 Linux. It runs fine on both of these. Again, my SHELL env variable and passwd entry both have '/usr/bin/ksh'. When I invoke the program on Red Hat 7.2 with './myprog', it is using the '/bin/sh' shell. Why would this be ? If my SHELL var and passwd entry both point to 'ksh', I don't understand how it would be using '/bin/sh'. Also, I can't just add the '#!' line to the top because this script invokes other scripts as well and it just pushes the problem to a different point. Any ideas ????

Then it is broken.

You have a finite number of scripts. And the #! line to each one.

As for what is happening, see this thread.

Thanks. This behavior was quite surprising to me and my co-workers. We always thought that the system will use whatever your current $SHELL is to run scripts without the "#!". This script is a setup script for a bigger program and it was always without the "#!". I guess I'll add it to the top of the file now that I know.

The second shell for unix was csh. Shortly after csh arrived, the SHELL environment variable was introduced. It was set to the value of the shell field in /etc/passwd. From it's inception, it was intended to be the user's favorite interactive shell. Programs like vi refer to it when when they are asked to spawn an interactive shell. If it also was for scripts, that would mean that we must use the same shell for interactive use and for scripts. csh was better than sh as an interactive shell but sh was better than csh for scripts.

The only exception to this that I know of is with the program "make". It reads the environment and treats each environment variable as a make macro. That includes the SHELL macro, the environment SHELL variable overrides make's internal deafault for SHELL. So all non-trivial makefiles now explicitly set the SHELL macro. make's habit of assuming that the entire environment is intended for it is not great behavior.