HP-UX HB v13.00 Ch-11 - Software Development

HP-UX Handbook Rev 13.00 Page 44 (of 101)
Chapter 11 Software Development
October 29, 2013
All shells know three operating modes. When calling a shell with an argument, it enters the
automatic mode, which expects the argument to be a script. The shell interprets the script and if
the script exits, the shell exits too. If no argument is given to the shell, it is started in interactive
mode where it prints a command prompt and waits for user input. If a shell is started with a
leading "-", it is started as a login shell, which means that it reads its startup files before it enters
the interactive mode. It is not possible to start a login shell from the command line. The leading
-“ required for a login shell can only be inserted when using the exec(2) libc functions.
The shell which is started after login can be set to any shell available on the system by specifying
it in the last field in /etc/passwd, e.g.
root:2eRyvWzYVvtzc:0:3:,,,:/:/sbin/sh
Default shell variables (environment variables) can be set system wide in /etc/csh.login (csh)
resp. /etc/profile (other shells) and user specific in ~/.login (csh) resp. ~/.profile (other
shells).
Common shell features are described in the following table:
Feature
POSIX
Korn
C
Key
Alias
Arithmetic Operations
Arrays
Autoload
Command line editor
Command substitution
File name expansion
History
Job control
Variable prompt string
POSIX Shell
The POSIX.2 standard requires that, on a POSIX-compliant system, executing the command sh
will start a POSIX compliant shell. The POSIX shell is in many respects very similar to the Korn
shell, but has some additional enhancements.
If a command is invoked in the POSIX shell, it first searches for a function, then for built-in
commands and at last for external commands.