In bash file first line should specify the path to interpreter.
But on different servers Linux, Unix, or BSD this path could be different.
What is more preferable
#!/usr/bin/env bash
or
#!/bin/bash
|
In bash file first line should specify the path to interpreter. What is more preferable
or
|
||||
|
|
|
If you want to use the system-installed version of a given interpreter that's installed in a standard location, use the direct path. If you want to use whatever version of the interpreter appears first in the user's The
If you don't specify any environment variables or other options, it will just invoke the named command. (Using it this way is arguably a bit of a hack.) The purpose of writing the shebang as
is to invoke whatever This means you don't have to know, when writing the script, exactly where The advantage is that it invokes whichever version of the interpreter appears first in the user's For example, suppose I've installed a personal build of
then it's going to be run with my own installed For something like Perl or Bash that's likely to be installed in a consistent location on most systems ( |
|||||
|
|
The best practice is this:
And so on... When Ubuntu first started using dash, some scripts broke. There was discussion about it.
Most scripts were written |
|||
|
|
|
FYI it is a shee-bang By default, Ubuntu links Depending on how much you might like to know about dash and why dash is used for system or deamon shells see: Bash is the default shell used by most Linux users, and has different features then dash. A script written for bash may or may not run properly if run with dash, the more complex the script the less likely it will run. Script written for perl, python, etc. will not run at all with So when you write a script, you identify what interpreter should be used with the shee-bang The selection of what to use is made by the author of the script, and one is not better then another, they all have various features, advantages, and disadvantages. |
||||
|
|