|Linux Standard Base Core Specification, Generic Part|
|<<< Previous||Chapter 20. Additional Behaviors||Next >>>|
An executable script is an executable file of which the first two characters are #! as defined in the portable character set. In POSIX 1003.1-2008 (ISO/IEC 9945-2009), this construct is undefined, but reserved for implementations which wish to provide this functionality. LSB conforming implementations shall support executable scripts.
A successful call to a function of the exec family with an executable script as the first parameter shall result in a new process, where the process image started is that of the interpreter. The path name of the interpreter follows the #! characters.
If the executable script has a first line
The interpreter shall not perform any operations on the first line of an executable script.
The first line of the executable script shall meet all of the following criteria otherwise the results are unspecified:
Is of one of the forms:
The interpreter argument is an absolute pathname of an executable file other than an executable script.
Neither the interpreter argument nor the arg argument, if present, contain any quoting characters.
Neither the interpreter argument nor the arg argument, if present, contain any whitespace characters.
The length of the entire line is no longer than 80 bytes.
If the interpreter is required by this specification to be in a specfic named directory, a conforming application must use that path for interpreter, as implementations are not prohibited from having other, possibly non-conforming, versions of the same interpreter installed on the system. If the interpreter is a required command in this specification, but does not have a required path, the application should take special measures to insure the appropriate version is selected. If the interpreter is not a required command in this specification, the application must make appropriate provisions that the interpreter is available at the appropriate path.
Note: In case the path is not specified, it is recommended that an installation script for executable scripts use the standard
PATHreturned by a call to the getconf command with the argument PATH, combined with the command command to determine the location of a standard command.
For example to determine the location of the standard awk command:
The installation script should ensure that the returned pathname is an absolute pathname prior to use, since a shell builtin might be returned for some utilities.
Use of the common form #!/usr/bin/env interpreter is not recommended as the
PATHwill be unknown at execution time and an alternative version of interpreter might be selected.