HP-UX Reference (11i v2 07/12) - 1 User Commands N-Z (vol 2)

s
sh-posix(1) sh-posix(1)
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 equal 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*() 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, sh is spawned to interpret the script file. All nonexported aliases, functions, and named
parameters are removed in this case. If the shell command file does not have read permission, or if the
setuid and/or setgid
bits are set on the file, the shell executes an agent to set up the permissions and
execute the shell with the shell command file passed down as an open file. A parenthesized command is
also executed in a subshell without removing nonexported quantities.
Command Reentry
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 com-
mand
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 you do not specify an editor program as an argument to
fc, the
value of the parameter
FCEDIT is used. If FCEDIT is not defined, /usr/bin/ed is used. The edited
command is printed and reexecuted upon leaving the editor. The editor name
- is used to skip the editing
phase and to reexecute 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
reexecutes 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 occurs:
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.
Command Line Editing
Normally, each command line typed at a terminal device is followed by a newline or return. If one of the
emacs, gmacs, vi,orviraw, options is set, you can edit the command line. An editing option is
automatically selected each time the
VISUAL or EDITOR variable is assigned a value ending in one of
these option names.
The editing features require that the user’s terminal accept return without line feed and that a space (" ")
must overwrite the current character on the screen. ADM terminal users should set the "space advance"
switch to "space". Hewlett-Packard terminal users should set the straps to "bcGHxZ etX".
The editing modes enable the user to look through a window at the current line. The default window width
is 80, unless the value of
COLUMNS is defined. If the line is longer than the window width minus two, a
mark displayed at the end of the window notifies the user. The mark is one of:
> The line extends to the right.
< The line extends to the left.
* The line extends to both sides of the window.
As the cursor moves and reaches the window boundaries, the window is centered about the cursor.
The search commands in each edit mode provide access to the history file. Only strings are matched, not
patterns, although a leading ˆ in the string restricts the match to begin at the first character in the line.
Changing the LC_TYPE environment variable can affect the editors. See the Parameter Substitution sub-
section.
HP-UX 11i Version 2: December 2007 Update 21 Hewlett-Packard Company 285