Open System Services Shell and Utilities Reference Manual (G06.27+, H06.04+)

sh(1) OSS Shell and Utilities Reference Manual
Command Reentry
The text of the last HISTSIZE (default 128) commands entered from a terminal device is saved
in a history le. The $HOME/.sh_history le is used if the HISTFILE variable is not set or is
not writable. A shell can access the commands of all interactive shells that use the same named
HISTFILE. The fc special command is used to list or edit a portion of this le. The portion of
the le to be edited or listed can be selected by number or by giving the rst character or charac-
ters of the command. A single command or range of commands can be specied. If you do not
specify an editor program as an argument to fc, then the value of the FCEDIT parameter is used.
If FCEDIT is not dened, then /usr/bin/ed is used. The edited commands are printed and reexe-
cuted upon leaving the editor. The editor name - (dash) 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 -, then typing r
bad=good c reexecutes the most recent command, which starts with the letter c, replacing the
rst occurrence of the string bad with the string good.
Inline Editing Options
Normally, each command line entered from a terminal device is simply typed followed by a new-
line character (<Return> or linefeed). If the vi option is active, you can edit the command line.
To be in this edit mode, set the corresponding option. An editing option is automatically selected
each time the VISUAL or EDITOR variable is assigned a value ending in the option name.
The editing features require that the terminal accept <Return> as carriage-return without
linefeed 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 series 2621 terminal users
should set the straps to bcGHxZ etX.
The editing modes create the impression that the user is looking through a window at the current
line. The window width is the value of COLUMNS if it is dened, otherwise it is 80 bytes. If
the line is longer than the window width minus 2, a mark is displayed at the end of the window to
notify the user. As the cursor moves and reaches the window boundaries, the window will be
centered about the cursor. The mark is a > (right angle bracket) if the line extends on the right
side of the window, a < (left angle bracket) if the line extends on the left side of the window, and
an * (asterisk) if the line extends on both sides of the window.
The search commands in each edit mode provide access to the history le. Only strings are
matched, not patterns, although if the leading character in the string is a ˆ (circumex), the match
is restricted to begin at the rst character in the line.
The vi Editing Mode
There are two typing modes. Initially, when you enter a command you are in the input mode. To
edit, the user enters control mode by typing <Esc> (ASCII 033) and moves the cursor to the
place needing correction and then inserts or deletes characters or words as needed. Most control
commands accept an optional repeat count prior to the command. When in vi mode on most sys-
tems, canonical processing is initially enabled and the commands are echoed again if the speed is
1200 baud or greater, if it contains any control characters, or if less than 1 second has elapsed
since the prompt was printed. The Escape character terminates canonical processing for the
remainder of the command and the user can then modify the command line.
This scheme of using two typing nodes has the advantages of canonical processing with the
type-ahead echoing of raw mode. If the option viraw is also set, the terminal always has canoni-
cal processing disabled. This mode is implicit for systems that do not support two alternative
End-of-Line delimiters, and can be helpful for certain terminals.
830 Hewlett-Packard Company 527188-004