Program location Shebangs must specify
absolute paths (or paths relative to current working directory) to system executables; this can cause problems on systems that have a non-standard
file system layout. Even when systems have fairly standard paths, it is quite possible for variants of the same operating system to have different locations for the desired interpreter.
Python, for example, might be in
/usr/bin/python3,
/usr/local/bin/python3, or even something like
/home/username/bin/python3 if installed by an ordinary user. A similar problem exists for the
POSIX shell, since POSIX only required its name to be
sh, but did not mandate a path. A common value is , but some systems such as Solaris have the POSIX-compatible shell at
/usr/xpg4/bin/sh. In many
Linux systems,
/bin/sh is a hard or
symbolic link to
/bin/bash, the
Bourne Again shell (BASH). Using bash-specific syntax while maintaining a shebang pointing to
sh is also not portable. Because of this it is sometimes required to edit the shebang line after copying a
script from one computer to another because the path that was coded into the script may not apply on a new machine, depending on the consistency in past convention of placement of the interpreter. For this reason and because
POSIX does not standardize path names, POSIX does not standardize the feature. The
GNU Autoconf tool can test for system support with the macro AC_SYS_INTERPRETER. Often, the program can be used to circumvent this limitation by introducing a level of
indirection. is followed by , followed by the desired command without full path, as in this example: #!/usr/bin/env sh This mostly works because the path is commonly used for the utility, and it invokes the first found in the user's
$PATH, typically . This particular example (using ) is of limited utility: neither nor is universal, with similar numbers of devices lacking each. More broadly using for any script still has some portability issues with
OpenServer 5.0.6 and
Unicos 9.0.2 which have only and no . Using results in
run-time indirection, which has the potential to degrade system security; for this reason some commentators recommend against its use in packaged software, reserving it only for "educational examples".
Argument splitting Command arguments are split in different ways across platforms. Some systems do not split up the arguments; for example, when running the script with the first line, #!/usr/bin/env python3 -c all text after the first space is treated as a single argument, that is, will be passed as one argument to , rather than two arguments. Such systems include Linux and
Cygwin. Another approach is the use of a
wrapper. FreeBSD 6.0 (2005) introduced a option to its as it changed the shebang-reading behavior to non-splitting. This option tells to split the string itself. The GNU utility since
coreutils 8.30 (2018) also includes this feature. Although using this option mitigates the portability issue on the kernel end with splitting, it adds the requirement that supports this particular extension.
Character interpretation Another problem is scripts containing a
carriage return character immediately after the shebang line, perhaps as a result of being edited on a system that uses DOS
line breaks, such as
Microsoft Windows. Some systems interpret the carriage return character as part of the
interpreter command, resulting in an error message.
Magic number The shebang is actually a human-readable instance of a
magic number in the executable file, the
magic byte string being , the two-character encoding in
ASCII of . This magic number is detected by the "
exec" family of functions, which determine whether a file is a script or an executable binary. The presence of the shebang will result in the execution of the specified executable, usually an interpreter for the script's language. It has been claimed that some old versions of Unix expect the normal shebang to be followed by a space and a slash (''''), but this appears to be untrue; ==Etymology==