ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The point of specifying the shell your code requires (on production systems) is so that you don't end up with a script that partially runs, then screws up/crashes because it's running under the wrong intepreter.
It's much safer for it not to run at all if it can't find the correct interpreter.
It can cost a company a lot of money if it goes wrong...
It also tells the sysadmin/maintenance prog which shell it will work with, rather than them having to guess.
You might not be avail to be asked when it goes pear-shaped ...
If you are calling a script as the argument to a shell, the shebang makes no difference; it is just another comment. The shebang is only used when the script is executed as a command.
This is an important point. Previously, I think if we add shebang into the 1st line of shell script and at the same time using sh to execute, shell process will be started twice (1st time sh, 2nd time by the shebang line).
The portability of scripts is decreased if you specify an absolute path.
I once used Solaris often and ran into such problems going back and forth to and from Linux.
I use a perl utility, fixin (fix interpreter), that adjusts the shebang line of scripts for the correct path. It works not only for perl shebangs, but for anything you have in a shebang -- awk, sh, etc.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.