hash-bang- execute an interpreter on a file
hash-pling- execute an interpreter on a file
hash-shriek- execute an interpreter on a file
i286emul- i286 COFF binary emulator
x286emul- x8086/x80286 OMF (x.out) binary emulator
The UNIX system contains several shells; these are interactive command interpreters. This manual page describes how the Bourne, C, and Korn shells (see sh(C), csh(C), and ksh(C)) execute commands that you have entered.
When you enter a command, the shell tries to match it against several possible entities in order to run it:
There are two types of executable file that may be run:
The Korn shell tries to avoid forking if it can. It must fork if the file being executed is not a Korn shell script or if it forms the second or subsequent element of a command pipeline; in these two cases execution proceeds as for the Bourne and C shells. Whenever possible, the Korn shell interprets and runs the commands in the file without calling fork. The shell protects the main execution environment from the effects of commands in the script; this emulates the behavior of a forked process without the consequent overhead.
---------------------------------------------------------
Module type Emulator or direct
---------------------------------------------------------
i386 ELF binary direct
i386 COFF binary direct
i386 OMF (x.out) binary direct
i286 COFF binary emulator
(/bin/i286emul)
x8086/x80286 OMF (x.out) binary emulator
(/bin/x286emul)
DOS executable or batch file emulator (if available)
If a DOS emulator is available on your system,
exec uses it to run DOS executable and batch files.
See
dos(MERGE)
for more information.
exec appends all command line arguments (including $0) to the command interpreter and a single optional argument, and loads the resulting command to replace the child shell (see ``Examples''). interpreter must always be fully specified including its path; the form of exec that is used does not search the directories defined by the PATH environment variable.
If the second and subsequent lines of the script are to be interpreted by interpreter, the script must be readable by the invoking user, or interpreter must change the effective user or group ID to one that can read it.
#! scripts are also sometimes referred to as ``hash-bang'', ``hash-pling'', or even ``hash-shriek'' scripts.
#!/bin/echo args:Entering bing one two three four displays:
args: pathname/bing one two three four
pathname is displayed as an absolute or relative path to the bing script.
A #! script that must always be executed by /bin/sh:
#!/bin/sh ...A common use of #! is to introduce an executable awk(C) script:
#!/usr/bin/awk -f
#
BEGIN { FS = ":" }
...
Similarly, #! can be used to introduce a
sed(C)
script:
#!/bin/sed -f # s/foo/bar/ ...
Only one argument can be passed to the interpreter named after the #! entry. Some interpreters require the use of an option to tell them that the next argument is the script filename. For example, you must specify the -f option with both awk and sed.
The interpreter must understand the use of ``#'' to begin comment lines.
Earlier versions of the operating system either did not include the #! feature, or allowed it to be disabled.
A DOS emulator must be available on your system in
order to run DOS executables and batch files.
SCO OpenServer Release 5.0.6 -- 1 August 2000