HSH 5/2/81 HSH NAME hsh - shell with history and editing functions SYNOPSIS hsh [-cdnvx] [file] [arguments] DESCRIPTION `hsh' is identical to `sh' with the exception that a history is kept of commands typed; recall and editing functions on the history are permitted and described below. Consult the manual entry for `sh' for more information on the common functions. A history of the commands input to `hsh' are maintained for each session. The user may invoke special history manipulating functions by starting a command line with an exclamation mark (! - also known as a BANG) in column 1. If is is necessary to send a line starting with a BANG to the shell, lines starting with "@!" have the "@" stripped off, and the remainder of the line is given to the shell. Lines starting with BANG enable the user to communicate with a miniature version of the editor `ed'. At any time, the last 25 commands are available for recall and manipulation. The current line concept of `ed' is supported, although the current line is ALWAYS the last command in the history. Legal history commands are: 1. history display !h[istory] [n][l] This is the equivalent of a browse command in `ed'. !h will display the last screenful of commands, along with their line numbers. The screensize, which defaults to 22 lines, may be changed by specifying a BLANK and a number following the !h[istory] string (!h 10, for example). The new screensize is remembered and used in all !h commands as the default screensize. Specifying a screensize larger than 25 has the effect of setting the size to 25. The optional trailing `l' (list) will cause control characters in the commands to be displayed as `^', where is the character one needs to type in conjunction with the CTRL key to generate the control character. !b[rowse] [n][l] This command is a synonym for history. It is included to increase the similiarity of function with the editor. -1- HSH 5/2/81 HSH 2. history recall ![line_number][;line_number]... This command permits the recall of a command from the history for re-execution. The command so recalled is displayed to the user and then passed on to the shell for execution. This command is then entered at the bottom of the history. Valid line_numbers are the same as those for the editor. For example, a line_number may be the number listed next to the command in the history display, a pattern of the form "\pattern[\]", which indicates a backward search in the 25 line history window, or a pattern of the form "/pattern[/]", indicating a search forward, wrapping to the start of the 25 line window. The trailing '\' or '/' are optional when specifying a single pattern. The semi-colon syntax is the same as that in `ed', indicating that the search for the second pattern is to start at the line where the first pattern was found. If the pattern specified was illegal, or a line matching the pattern could not be found, or an invalid line_number was specified, a comment is displayed to the user # invalid line number and the user is prompted for more input. The history is not modified in this case. All sequences of patterns resolve into a single line number. It is not possible to request a range of lines from the history. It should be noted that the line_numbering is completely regular with `ed'. In particular, "!" followed by nothing maps into a fetch of the current line (last command typed). See the writeup on `ed' for more details on the specification of line_numbers. 3. history recall and modification ![line_number]s/pat/repl[/[g]] Upon successfully recalling a command from the history, it may be modified before it is passed on to `hsh' for execution. This is performed with the 's' command, which is exactly the same as that for `ed'. The delimiters for `pat' and `repl' may be any character, the remembered -2- HSH 5/2/81 HSH pattern feature is available, and the trailing delimiter after the replacement pattern is optional. The optional trailing 'g' indicates substitution for all occurrences of 'pat' in the line. See the `ed' manual entry for more information on the substitute command. If the substitution fails for any reason, a comment is displayed to the user # illegal substitution and the user is prompted for more input. The history is not modified in this case. 4. history archiving !w[rite] [>[>]]file This command permits the user to archive (save) the entire transcript of activity to a file. It also passes an EOF to `hsh', which causes `hsh' to terminate execution. The commands !w file !w >file both cause `file' to be overwritten with the transcript, while >>file causes the transcript to be appended to `file'. It should be noted that the !w command causes ALL of the input given to `hsh' in this session to be saved, not just the current 25 line window. It also passes an EOF to `hsh', which will terminate execution. 5. history deletion !q[uit] ^Z These commands cause an EOF to be sent to `hsh' and the deletion of the log of activity. -3- HSH 5/2/81 HSH Lines consisting solely of a carriage return are NOT logged in the history. If the user needs to perform several edits on a command before having it executed, he can exploit the fact that lines beginning with a sharp (#) are comments to the shell. For example: !\%ed\s/%/#/ !s/pat1/repl1/ . . . . . . !s/patn/repln/ !s/%#// All of the intermediate comment lines will be placed in the history, displacing other lines from the window which may possibly be needed. Of course, it may be simpler in such cases to just enter the command by hand. FILES Creates a scratch file ~tmp/pid.log for the command transcript. SEE ALSO sh - command line interpreter rsh - shell with file recognition and RAW tty I/O ed - text editor DIAGNOSTICS # invalid line number # invalid substitution AUTHORS Joe Sventek BUGS -4-