.TH = 1 .SH NAME =, == \- redo previous shell command .SH SYNOPSIS .B = [ pattern ] [ substitutions ] .br .B == [ pattern ] [ substitutions ] .SH DESCRIPTION .I = provides a simple history mechanism for the shell, .IR sh (1). If the environment variable HISTORY is set, it names a file to which the shell appends the text of each command before execution. = reads the HISTORY file for the first previous command matching the .IR pattern, performs the .IR substitutions, and executes it. If no pattern is specified, the most recent command is selected. If no substitution is specified, the command is executed without modification. .PP The pattern matching works for literal text, and is anchored to the beginning of the command line. Adjacent arguments in the pattern are treated as one argument formed of the original argument strings separated by spaces. .PP Substitutions are of the form .br .in +5 old=new .in .br specifying that the string `old' in the command is to be replaced by `new.' Substitutions are performed in the order given, and operate on the single leftmost match in the command line. .PP The == command is identical to the = command, but before running the command (and after substitutions) allows it to be edited. The command is typed out, and a modification request is read from the terminal. Generally each character in the request specifies how to modify the character immediately above it, in the original command, as described in the following table. .IP # 5 Delete the above character. .PD 0 .IP % 5 Replace the above character with a space. .IP ^ 5 Insert the rest of the request line before the above character. .IP $ 5 Delete the characters in the command from this position on; replace them with the rest of the request line. .IP "space or tab" 5 Leave above character(s) unchanged. .IP = 5 as the first and only edit character. Back up to the prior occurrence of the pattern in the history file; this may be iterated, and the displayed lines will be unique. .IP "any other" 5 This character replaces the one above it. .PD .PP If the request line is longer than the command, the overhang is added to the end of the command without interpretation, that is, without treating `#', `%', `^' or `$' specially. Any characters after a `^' or `$' request are not interpreted either. .PP While correlating character positions, the editor will not process control characters other than tab and newline. .PP The tab character prints as a sequence of spaces, and may be modified as if it were that sequence. As long as the last space is unmodified, it and the remaining contiguous spaces will represent a tab. .PP The history mechanism performs best if each login terminal uses a different HISTORY file. The following commands accomplish this. .IP .nf HISTORY=$HOME/hist/\`basename \e\`tty\|\e\`\` >$HISTORY export HISTORY .fi