HISTORY(1)                                                          HISTORY(1)



NNAAMMEE
       -, --, -p, --p - shell history programs

SSYYNNOOPPSSIISS
       -- [_p_a_t_t_e_r_n...]  [_s_u_b_s_t_i_t_u_t_i_o_n...]

DDEESSCCRRIIPPTTIIOONN
       This set of programs provides a crude history mechanism for the shell
       _r_c(1).  It is based on the v8 UNIX programs _=, _=_=, etc.

       The program ``_-'' runs the shell on the command it is requested to
       find.  The program ``_-_-'' edits that command first.  The programs
       ``_-_p'' and ``_-_-_p'' are similar, except that they print the final
       command on their standard output instead of running the shell.

       The commands work by looking for a file named by the environment
       variable $history, and by searching for previous commands in this file.
       Old commands can be edited, or simply re-executed according to the
       rules below:

       A command is searched for by examining the lines in $history in reverse
       order.  Lines which contain a previous invocation of the history
       program itself are ignored.  If one or more _p_a_t_t_e_r_n is supplied on the
       command line, then the patterns are used as a means of limiting the
       search.  Patterns match any substring of a previous command, and if
       more than one pattern is present then all patterns must be matched
       before a command is selected.

       Substitutions may also be specified on the command line.  These have
       the syntax:

            _o_l_d:_n_e_w

       (Note that the _o_l_d pattern is used as a search-limiting pattern also.)
       Substitutions happen on the first match.

       Finally, if the program was invoked as ``_-_-'' or ``_-_-_p'', a command may
       be edited in a crude line-mode fashion.  The line to be edited is
       printed out, and below it the user supplies modifications to the
       command.

       aannyy cchhaarraacctteerr eexxcceepptt tthhoossee bbeellooww
              Replaces the character above.

       ssppaaccee oorr ttaabb
              Skips over the above character(s).

       ##      Deletes one character.

       %%      Replaces one character with a space.

       ^^      Inserts the rest of the typed line just before the character.

       $$      Deletes the rest of the line from that character on, and
              replaces it with the rest of the typed line.

       ++      Appends the rest of the typed line.

       --      Backs up to a previous command satisfying the same matching
              constraints.

       eenndd ooff lliinnee
              If any changes have been made, the command is printed out again
              for further editing.  If no changes have been made, the command
              is executed or printed, and the program exits.

       eenndd ooff ffiillee
              If an end-of-file is read from the keyboard by the editor, it
              aborts with exit status 1 and does not produce any output.

EEXXAAMMPPLLEESS
       The history programs work best when their output is reinterpreted by
       the shell using an eval command.  This can be achieved by writing a
       shell function to perform the reinterpretation:

            fn - -- {
                 comm = `{$0^p $*}
                 if (! ~ $#comm 0) {
                      echo $comm >[1=2]
                      eval $comm
                 }
            }



                                 30 July 1991                       HISTORY(1)
