HP-UX Reference (11i v1 05/09) - 1 User Commands A-M (vol 1)

k
ksh(1) ksh(1)
execute the command using exec (see exec(2)).
The shell parameter
PATH defines the search path for the directory containing the command. Alternative
directory names are separated by a colon (
:). The default path is /usr/bin: (specifying /usr/bin
and the current directory in that order). Note that the current directory is specified by a null path name
which can appear immediately after the equals sign, between colon delimiters, or at the end of the path list.
The search path is not used if the command name contains a
/. Otherwise, each directory in the path is
searched for an executable file. If the file has execute permissions but is not a directory or an executable
object code file, it is assumed to be a script file, which is a file of data for an interpreter. If the first two
characters of the script file are
#!, exec (see exec(2)) expects an interpreter path name to follow. exec
then attempts to execute the specified interpreter as a separate process to read the entire script file. If a
call to exec fails, /usr/bin/ksh is spawned to interpret the script file. All non-exported aliases, func-
tions, and named parameters are removed in this case. If the shell command file does not have read per-
mission, or if the setuid and/or setgid bits are set on the file, the shell executes an agent to set up the per-
missions and execute the shell with the shell command le passed down as an open file. A parenthesized
command is also executed in a sub-shell without removing non-exported quantities.
Command Re-entry
The text of the last
HISTSIZE (default 128) commands entered from a terminal device is saved in a his-
tory file. The file
$HOME/.sh_history
is used if the HISTFILE variable is not set or writable. A
shell can access the commands of all interactive shells that use the same named
HISTFILE. The special
command
fc is used to list or edit a portion of this file. The portion of the file to be edited or listed can be
selected by number or by giving the first character or characters of the command. A single command or
range of commands can be specified. If no editor program is specified as an argument to
fc, the value of
the
FCEDIT parameter is used. If FCEDIT is not defined, /usr/bin/ed is used. The edited com-
mand is printed and re-executed upon leaving the editor. The editor name - is used to skip the editing
phase and to re-execute the command. In this case a substitution parameter of the form old=
new can be
used to modify the command before execution. For example, if
r is aliased to fc -e -
, typing r
bad=good c
re-executes the most recent command that starts with the letter c and replaces the first
occurrence of the string bad with the string good.
The history file will be trimmed when all of the following conditions occur:
Its size is greater than four kilobytes.
The number of commands in it is more than HISTSIZE.
The file has not been modified in the last ten minutes.
The user has write permission for the directory in which the history file resides.
If any one of the above conditions does not occur, the history file will not be trimmed. When the history file
is trimmed, the latest HISTSIZE commands will be available in the history file.
Special Commands
The following simple-commands are executed in the shell process. They permit input/output redirection.
Unless otherwise indicated, file descriptor 1 is the default output location and the exit status, when there
are no syntax errors, is zero. Commands that are preceded by % or %% are treated specially in the follow-
ing ways:
1. Variable assignment lists preceding the command remain in effect when the command completes.
2. I/O redirections are processed after variable assignments.
3. Certain errors cause a script that contains them to abort.
4. Words following a command preceded by %% that are in the format of a variable assignment are
expanded with the same rules as a variable assignment. This means that tilde substitution is per-
formed after the = sign and word splitting and file name generation are not performed.
%:[arg ... ] The command only expands parameters. A zero exit code is returned.
%.file [arg ...]
Read and execute commands from file and return. The commands are executed in the
current shell environment. The search path specified by PATH is used to find the directory
containing file. If any arguments arg are given, they become the positional parameters.
Otherwise the positional parameters are unchanged. The exit status is the exit status of
the last command executed. It is not necessary that the execute permission bit be set for
file.
Section 1420 Hewlett-Packard Company 11 HP-UX 11i Version 1: September 2005