home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume1 / bourne / part7 < prev    next >
Internet Message Format  |  1986-11-30  |  33KB

  1. Date: Fri, 7 Jun 85 14:14:18 edt
  2. From: Arnold Robbins <gatech!arnold>
  3. Subject: Bourne shell history + tilde + job control + more (Part 7 of 9)
  4. Newsgroups: mod.sources
  5.  
  6. This is part 7 of 9.  It contains the diffs for the System V Release 2
  7. Bourne shell man page, sh.1.
  8.  
  9. BSD users who happen to also have source for System V Release 2 will probably
  10. want to use this version of the shell, since it has many bug fixes and
  11. improvements over the (much) earlier version that comes with Berkeley Unix.
  12.  
  13. Note that on a non-BSD system, you will have to edit the patched man page
  14. to remove all references to the I and J flags, and to the job control
  15. features.
  16.  
  17. Arnold Robbins
  18. arnold@gatech.{UUCP, CSNET}
  19. ----------- pretend your screen is really a paper towel ------------
  20. *** ../orig.u/sh.1    Wed May 15 17:23:11 1985
  21. --- sh.1    Thu Jun  6 09:11:54 1985
  22. ***************
  23. *** 34,40
  24.   .SH SYNOPSIS
  25.   .B sh
  26.   [
  27. ! .B \-acefhiknrstuvx
  28.   ] [ args ]
  29.   .br
  30.   .B rsh
  31.  
  32. --- 34,40 -----
  33.   .SH SYNOPSIS
  34.   .B sh
  35.   [
  36. ! .B \-acefhiknqrstuvxEHIJ
  37.   ] [ args ]
  38.   .br
  39.   .B rsh
  40. ***************
  41. *** 39,45
  42.   .br
  43.   .B rsh
  44.   [
  45. ! .B \-acefhiknrstuvx
  46.   ] [ args ]
  47.   .SH DESCRIPTION
  48.   .I Sh\^
  49.  
  50. --- 39,45 -----
  51.   .br
  52.   .B rsh
  53.   [
  54. ! .B \-acefhiknqrstuvxEHIJ
  55.   ] [ args ]
  56.   .SH DESCRIPTION
  57.   .I Sh\^
  58. ***************
  59. *** 72,77
  60.   .BR ? ,
  61.   .BR \- ,
  62.   .BR $ ,
  63.   and
  64.   .BR !\\^ .
  65.   .SS Commands
  66.  
  67. --- 72,78 -----
  68.   .BR ? ,
  69.   .BR \- ,
  70.   .BR $ ,
  71. + .BR + ,
  72.   and
  73.   .BR !\\^ .
  74.   .SS Commands
  75. ***************
  76. *** 446,451
  77.   .B $
  78.   The process number of this shell.
  79.   .TP
  80.   .B !
  81.   The process number of the last background command invoked.
  82.   .PD
  83.  
  84. --- 447,464 -----
  85.   .B $
  86.   The process number of this shell.
  87.   .TP
  88. + .B +
  89. + The process number of the parent of this shell.  In particular,
  90. + the value of
  91. + .B $+
  92. + will track the value of the
  93. + .IR getppid (2)
  94. + system calll.  I.e. if
  95. + .I init
  96. + should inherit this shell,
  97. + .B $+
  98. + will become 1.
  99. + .TP
  100.   .B !
  101.   The process number of the last background command invoked.
  102.   .PD
  103. ***************
  104. *** 552,557
  105.   below) for this name.
  106.   If it is found and there is an 'r' in the file name part of its value, the
  107.   shell becomes a restricted shell.
  108.   .PD
  109.   .RE
  110.   .PP
  111.  
  112. --- 565,576 -----
  113.   below) for this name.
  114.   If it is found and there is an 'r' in the file name part of its value, the
  115.   shell becomes a restricted shell.
  116. + .TP
  117. + .B
  118. + .SM HISTFILE
  119. + The file where command history is saved across login sessions.
  120. + The default value is
  121. + .BR \s-1$HOME\s+1/.history .
  122.   .PD
  123.   .RE
  124.   .PP
  125. ***************
  126. *** 556,562
  127.   .RE
  128.   .PP
  129.   The shell gives default values to
  130. ! \f3\s-1PATH\s+1\fP, \f3\s-1PS1\s+1\fP, \f3\s-1PS2\s+1\fP, \f3\s-1MAILCHECK\s+1\fP and \f3\s-1IFS\s+1\fP.
  131.   .SM
  132.   .B HOME
  133.   and
  134.  
  135. --- 575,582 -----
  136.   .RE
  137.   .PP
  138.   The shell gives default values to
  139. ! \f3\s-1HISTFILE\s+1\fP, \f3\s-1PATH\s+1\fP, \f3\s-1PS1\s+1\fP,
  140. ! \f3\s-1PS2\s+1\fP, \f3\s-1MAILCHECK\s+1\fP and \f3\s-1IFS\s+1\fP.
  141.   .SM
  142.   .B HOME
  143.   and
  144. ***************
  145. *** 564,569
  146.   .B MAIL
  147.   are set by
  148.   .IR login (1).
  149.   .SS Blank Interpretation
  150.   After parameter and command substitution,
  151.   the results of substitution are scanned for internal field separator
  152.  
  153. --- 584,810 -----
  154.   .B MAIL
  155.   are set by
  156.   .IR login (1).
  157. + .SS Tilde Substitution
  158. + An unquoted tilde character
  159. + .RB ( ~ )
  160. + will cause the shell to attempt a tilde substituion.  Tilde substitutions
  161. + are used to automatically determine home directories.  Both the current
  162. + user's home directory, and the home directory of any other user on
  163. + the system may be found.
  164. + .PP
  165. + A
  166. + .B ~
  167. + by itself is equivalent to using
  168. + .BR \s-1$HOME\s+1 .
  169. + E.g.
  170. + .B ~/bin
  171. + is the same as saying
  172. + .BR \s-1$HOME\s+1/bin .
  173. + The notation
  174. + .B ~person
  175. + will cause the shell to look up
  176. + .BR person 's
  177. + home directory in the
  178. + .B /etc/passwd
  179. + file, and substitute it in.  For example, if user
  180. + .BR arnold 's
  181. + home directory is
  182. + .BR /user/arnold ,
  183. + the shell would replace
  184. + .BR ~arnold/bin
  185. + with
  186. + .BR /user/arnold/bin .
  187. + .PP
  188. + Tilde substitutions are recognized at the beginning of words, after
  189. + equal signs (for shell variable assignment), in the middle of single letter
  190. + flag arguments to commands (e.g. \fBecho \-t~arnold\fP), and after
  191. + colons inside the
  192. + .B
  193. + .SM PATH
  194. + and
  195. + .B
  196. + .SM CDPATH
  197. + shell parameters.
  198. + .PP
  199. + If
  200. + .B /etc/passwd
  201. + cannot be read, or if
  202. + no user can be found to match the attempted tilde substitution,
  203. + the text is left unmodified.
  204. + .SS History Substitution
  205. + When reading input from an interactive terminal, a
  206. + .RB `` ! ''
  207. + character, anywhere on the line,
  208. + signals the shell that it should attempt
  209. + to perform a history substitution.
  210. + A history substitution is a shorthand method which allows the user
  211. + to recall all or part of a previous command, possibly editing the
  212. + recalled portion.
  213. + The recalled (and possibly changed) command line is then placed into
  214. + the current command line,
  215. + to be passed on to the rest of the shell for normal processing.
  216. + A history substitution takes the form:
  217. + .PP
  218. + .if t .RS
  219. + \fB!\fP\^[ \fIstr\fP | \fB?\fIstr\fB?\fR | \fInum\fP ]\c
  220. + [ \fB\(ga\fInum\fR [ \- [ \fInum\fP ] ]\c
  221. + { \fB^\fIstr\fB^\fIstr\fB^\fR [\fBg\fP] }
  222. + .if t .RE
  223. + .PP
  224. + A history substitution contains three parts;
  225. + command selection, argument selection, and editing.
  226. + .I Command selection
  227. + chooses what command will be retrieved from the stored
  228. + history.
  229. + .I Argument selection
  230. + chooses which arguments from that command will be extracted.
  231. + .I Editing
  232. + allows the user to change spelling or make a substitution.
  233. + .PP
  234. + The history substitution is triggered by the
  235. + .RB `` ! '',
  236. + and continues until another
  237. + .RB `` ! ''
  238. + is encountered, or until
  239. + something that could not be part of a history substitution is seen.
  240. + This is so that the
  241. + history substitution will be properly concatenated with the following text.
  242. + Whenever a history substitution is encountered and properly performed,
  243. + the shell echoes the resulting line to the terminal and then executes the
  244. + command.
  245. + .PP
  246. + History substitution occurs inside double quotes and grave accents, but will
  247. + not occur inside single quotes.  To get a literal
  248. + .RB `` ! ''
  249. + character, outside of single quotes, precede it with a
  250. + .BR \e .
  251. + The
  252. + .BR ? ,
  253. + .BR \(ga ,
  254. + and
  255. + .B ^
  256. + characters are treated specially by the history mechanism only when preceded
  257. + by a
  258. + .RB `` ! '',
  259. + otherwise they have their normal meaning
  260. + of ``match a single character'',
  261. + ``enclose a command substitution'',
  262. + and as a synonym for the \fB\(bv\fP
  263. + character.
  264. + .PP
  265. + The full meaning of the history syntax is as follows:
  266. + .RS
  267. + .TP
  268. + \fB!\fP\^[ \fIstr\fP | \fB?\fIstr\fB?\fR | \fInum\fP ]
  269. + The first thing in a history substitution is
  270. + .IR "command selection" .
  271. + This is used to retrieve a given command line for use, or for further
  272. + processing.  In a history command selection, \fB!\fIstr\fR
  273. + will find the most recent command line that started with the
  274. + characters in
  275. + .IR str .
  276. + \fB!?\fIstr\fB?\fR will find the most recent command line that contained
  277. + .I str
  278. + anywhere on the line.  It also allows
  279. + .I str
  280. + to contain blanks and tabs, whereas the first form does not.
  281. + \fB!\fInum\fR allows the user to specify the number of a command, according
  282. + to the output of the
  283. + .B history
  284. + command (see the section on special commands, below).
  285. + .TP
  286. + \fB\(ga\fInum\fR [ \- [ \fInum\fP ]
  287. + The next portion of a history substitution is an optional
  288. + .IR "argument selection" .
  289. + This chooses which portions of the command are to be kept.
  290. + History arguments are not exactly the same as the arguments the rest of
  291. + the shell uses, since history expansion occurs before argument collection.
  292. + Arguments in this context are blank or tab separated words on the command line.
  293. + Single or double quoted strings, strings inside grave accents, shell regular
  294. + expressions, commands in parentheses (which get executed in a subshell),
  295. + and commands enclosed in braces,
  296. + are all treated as single arguments for the history mechanism, even though
  297. + they may have white space in them.
  298. + .sp
  299. + Arguments are numbered from zero, starting at the leftmost portion of the
  300. + line.  In an argument selection, \fB\(ga\fInum\fR specifies that only argument
  301. + .I num
  302. + is to be extracted and kept for further processing or use, and the rest
  303. + of the command line is to be dropped.
  304. + \fB\(ga\fInum\fB\-\fInum\fR
  305. + specifies that the arguments from the first
  306. + .I num
  307. + to the last
  308. + .I num
  309. + are to be kept. In place of any
  310. + .IR num ,
  311. + .B $
  312. + may be specified to obtain the last argument on the line.
  313. + The form \fB\(ga\-\fInum\fR is a shorthand for \fB\(ga\fP1\fB\-\fInum\fR
  314. + and
  315. + \fB\(ga\fInum\fB\-\fR
  316. + is a short form for
  317. + \fB\(ga\fInum\fB\-$\fR.
  318. + Finally, the notation
  319. + \fB\(ga\-\fP
  320. + indicates all the arguments.  That is, \fB\(ga\-\fP implies
  321. + \fB\(ga1\-$\fP.
  322. + .TP
  323. + \fB^\fIstr\fB^\fIstr\fB^\fR [\fBg\fP]
  324. + The last portion of a history substitution is also optional, and is the
  325. + .I editing
  326. + phase.  This allows the remaining portions of the retrieved
  327. + command line to modified, like the substitute command in
  328. + .IR ed (1),
  329. + although in a much more limited fashion.
  330. + In the history mechanism,
  331. + .I str
  332. + is not a regular expression, as in
  333. + .IR ed,
  334. + but just a simple string.
  335. + The history mechanism does not recognize
  336. + either the shell's pattern matching characters or the editor's
  337. + regular expression characters.
  338. + Each substitution happens only once on a line, unless a trailing ``g''
  339. + is appended to the substitution.  In this case, the substitution occurs
  340. + globally (everywhere) on the line.
  341. + Substitutions may be strung together,
  342. + so that more than one can be done at once.
  343. + The trailing ``g'' may be in either upper or lower case.
  344. + .RE
  345. + .PP
  346. + Some examples of history substitution are given below.
  347. + Should a history substitution fail, the errant command will
  348. + .I not
  349. + be added to the history buffers.
  350. + .PP
  351. + The history mechanism recognizes lines that end with unbalanced quotes.
  352. + When the quotes are balanced on the next line(s), 
  353. + It will join this line with the one that opened the quotes, keeping the
  354. + embedded newline(s). So, e.g.,
  355. + .RS
  356. + .sp
  357. + .nf
  358. + .RB "$ " "echo 'open"
  359. + .RB "> " "close'"
  360. + .fi
  361. + .RE
  362. + .sp
  363. + will be saved as one history ``event.''
  364. + This does
  365. + .I not
  366. + extend to other shell constructs, like balancing parentheses across
  367. + newlines.
  368. + .PP
  369. + The history mechanism keeps a maximum of
  370. + 256
  371. + stored commands at any one time, and the total text of the
  372. + stored history may occupy no more than
  373. + 4096
  374. + characters.
  375. + Experience indicates that it is not necessary to store more than this,
  376. + and the extra history buffers should not make the shell too large for
  377. + machines with small address spaces (e.g. PDP-11's).
  378.   .SS Blank Interpretation
  379.   After history, tilde, parameter and command substitution,
  380.   the results of substitution are scanned for internal field separator
  381. ***************
  382. *** 565,571
  383.   are set by
  384.   .IR login (1).
  385.   .SS Blank Interpretation
  386. ! After parameter and command substitution,
  387.   the results of substitution are scanned for internal field separator
  388.   characters (those found in
  389.   .BR \s-1IFS\s+1 )
  390.  
  391. --- 806,812 -----
  392.   and the extra history buffers should not make the shell too large for
  393.   machines with small address spaces (e.g. PDP-11's).
  394.   .SS Blank Interpretation
  395. ! After history, tilde, parameter and command substitution,
  396.   the results of substitution are scanned for internal field separator
  397.   characters (those found in
  398.   .BR \s-1IFS\s+1 )
  399. ***************
  400. *** 616,622
  401.   matches any
  402.   character lexically between the pair, inclusive.
  403.   If the first character following the opening 
  404. ! \`\`\*(OK\'\'
  405.   is a
  406.   .B "``!''"
  407.   any character not enclosed is matched.
  408.  
  409. --- 857,863 -----
  410.   matches any
  411.   character lexically between the pair, inclusive.
  412.   If the first character following the opening 
  413. ! .RB `` \*(OK ''
  414.   is a
  415.   .RB `` ! ''
  416.   any character not enclosed is matched.
  417. ***************
  418. *** 618,624
  419.   If the first character following the opening 
  420.   \`\`\*(OK\'\'
  421.   is a
  422. ! .B "``!''"
  423.   any character not enclosed is matched.
  424.   .PD
  425.   .RE
  426.  
  427. --- 859,865 -----
  428.   If the first character following the opening 
  429.   .RB `` \*(OK ''
  430.   is a
  431. ! .RB `` ! ''
  432.   any character not enclosed is matched.
  433.   Note that when typing input from the terminal, the
  434.   .RB `` ! ''
  435. ***************
  436. *** 620,625
  437.   is a
  438.   .B "``!''"
  439.   any character not enclosed is matched.
  440.   .PD
  441.   .RE
  442.   .SS Quoting
  443.  
  444. --- 861,871 -----
  445.   is a
  446.   .RB `` ! ''
  447.   any character not enclosed is matched.
  448. + Note that when typing input from the terminal, the
  449. + .RB `` ! ''
  450. + should be preceded by a
  451. + .BR \e ,
  452. + so that the shell does not attempt to perform a history substitution.
  453.   .PD
  454.   .RE
  455.   .SS Quoting
  456. ***************
  457. *** 644,650
  458.   are quoted.
  459.   Inside double quote marks
  460.   (\f3"\^"\fP),
  461. ! parameter and command substitution occurs and
  462.   .B \e
  463.   quotes the characters
  464.   .BR \e ,
  465.  
  466. --- 890,896 -----
  467.   are quoted.
  468.   Inside double quote marks
  469.   (\f3"\^"\fP),
  470. ! history, parameter and command substitution occurs and
  471.   .B \e
  472.   quotes the characters
  473.   .BR \e ,
  474. ***************
  475. *** 650,655
  476.   .BR \e ,
  477.   .BR \*` ,
  478.   \f3"\fP,
  479.   and
  480.   .BR $ .
  481.   .B
  482.  
  483. --- 896,902 -----
  484.   .BR \e ,
  485.   .BR \*` ,
  486.   \f3"\fP,
  487. + .BR ! ,
  488.   and
  489.   .BR $ .
  490.   .B
  491. ***************
  492. *** 671,676
  493.   .SM
  494.   .B PS1
  495.   before reading a command.
  496.   If at any time a new-line is typed and further input is needed
  497.   to complete a command, the secondary prompt
  498.   (i.e., the value of
  499.  
  500. --- 918,934 -----
  501.   .SM
  502.   .B PS1
  503.   before reading a command.
  504. + If the user is super-user and
  505. + .SM
  506. + .B PS1
  507. + is not set to
  508. + .RB `` "# \|" ''
  509. + already, the
  510. + .SM
  511. + .B PS1
  512. + prompt is followed by
  513. + .RB `` "# \|" ''
  514. + as a BRL-supplied safety reminder.
  515.   If at any time a new-line is typed and further input is needed
  516.   to complete a command, the secondary prompt
  517.   (i.e., the value of
  518. ***************
  519. *** 676,681
  520.   (i.e., the value of
  521.   .BR \s-1PS2\s+1 )
  522.   is issued.
  523.   .SS Input/Output
  524.   Before a command is executed, its input and output
  525.   may be redirected using a special notation interpreted by the shell.
  526.  
  527. --- 934,996 -----
  528.   (i.e., the value of
  529.   .BR \s-1PS2\s+1 )
  530.   is issued.
  531. + .PP
  532. + Many people like to have the shell provide them with useful information
  533. + in their prompt.  To accomadate this, the shell will recognize special
  534. + sequences of characters in the value of
  535. + .BR PS1 ,
  536. + and substitute the appropriate information for them.
  537. + The special sequences and what they signify are:
  538. + .RS
  539. + .TP
  540. + .B %d
  541. + Place the current working directory into the prompt.
  542. + .TP
  543. + .B %e
  544. + Place the current event number (as defined by the
  545. + .B history
  546. + command) into the prompt.
  547. + If history evaluation has been turned off (via
  548. + .BR "set -H" ),
  549. + no number will be substituted in (i.e. the
  550. + .B %e
  551. + will be removed).
  552. + .TP
  553. + .B %h
  554. + Place the machine's host name into the prompt.  The host name is usually
  555. + the name by which the machine is known to the outside world for electronic
  556. + mail addressing.
  557. + .TP
  558. + .B %l
  559. + Place the user's login name into the prompt.
  560. + The login name selected is the first entry in the
  561. + .B /etc/passwd
  562. + file whose
  563. + .I uid
  564. + matches the value of the
  565. + .IR getuid (2)
  566. + system call.
  567. + This will be a problem on systems where multiple users share the same
  568. + user-id number.
  569. + .TP
  570. + .B %t
  571. + Place the current time of day, in the form \s-1HH:MM\s+1 into the prompt.
  572. + The time is on a 24 hour clock, i.e. 1:30 in the afternoon will be 13:30.
  573. + .TP
  574. + .BI % x
  575. + Place the character
  576. + .I x
  577. + into the prompt.
  578. + If the user wishes to put a literal
  579. + .B %
  580. + into the prompt, then
  581. + .B PS1
  582. + should have
  583. + .B %%
  584. + in it.
  585. + .RE
  586. + .PP
  587. + Some of these facilities are of more use than others.
  588.   .SS Input/Output
  589.   Before a command is executed, its input and output
  590.   may be redirected using a special notation interpreted by the shell.
  591. ***************
  592. *** 741,746
  593.   all leading tabs are stripped from
  594.   .I word\^
  595.   and from the document.
  596.   .TP
  597.   .B <\h@-.1m@&digit
  598.   Use the file associated with file descriptor
  599.  
  600. --- 1056,1063 -----
  601.   all leading tabs are stripped from
  602.   .I word\^
  603.   and from the document.
  604. + History substitution is turned off
  605. + while processing the document.
  606.   .TP
  607.   .B <\h@-.1m@&digit
  608.   Use the file associated with file descriptor
  609. ***************
  610. *** 753,758
  611.   The standard input is closed.
  612.   Similarly for the standard output using
  613.   .BR >\h@-.1m@&\h@-.1m@\- .
  614.   .PD
  615.   .PP
  616.   If any of the above is preceded by a digit,
  617.  
  618. --- 1070,1083 -----
  619.   The standard input is closed.
  620.   Similarly for the standard output using
  621.   .BR >\h@-.1m@&\h@-.1m@\- .
  622. + .TP
  623. + .B <\&>\&word
  624. + Use file
  625. + .I word
  626. + for standard input (file descriptor 0),
  627. + but open it for reading
  628. + .I and
  629. + writing.
  630.   .PD
  631.   .PP
  632.   If any of the above is preceded by a digit,
  633. ***************
  634. *** 824,830
  635.   .BR "set -a" ).
  636.   A parameter may be removed from the environment
  637.   with the 
  638. ! .BR unset command.
  639.   The environment seen by any executed command is thus composed
  640.   of any unmodified name-value pairs originally inherited by the shell,
  641.   minus any pairs removed by
  642.  
  643. --- 1149,1156 -----
  644.   .BR "set -a" ).
  645.   A parameter may be removed from the environment
  646.   with the 
  647. ! .BR unset
  648. ! command.
  649.   The environment seen by any executed command is thus composed
  650.   of any unmodified name-value pairs originally inherited by the shell,
  651.   minus any pairs removed by
  652. ***************
  653. *** 859,865
  654.   The following
  655.   first prints
  656.   .B "a=b c"
  657. ! and
  658.   .BR c :
  659.   .PP
  660.   .RS
  661.  
  662. --- 1185,1191 -----
  663.   The following
  664.   first prints
  665.   .B "a=b c"
  666. ! and then
  667.   .BR c :
  668.   .PP
  669.   .RS
  670. ***************
  671. *** 880,885
  672.   the
  673.   .B trap
  674.   command below).
  675.   .SS Execution
  676.   Each time a command is executed, the above substitutions are
  677.   carried out.
  678.  
  679. --- 1206,1214 -----
  680.   the
  681.   .B trap
  682.   command below).
  683. + When job control is enabled,
  684. + \s-1SIGTSTP\s0
  685. + causes a foreground command to be stopped.
  686.   .SS Execution
  687.   Each time a command is executed, the above substitutions are
  688.   carried out.
  689. ***************
  690. *** 945,951
  691.   .B 
  692.   .SM PATH
  693.   variable is changed or the
  694. ! .B hash -r
  695.   command is executed (see below).
  696.   .SS Special Commands
  697.   Input/output redirection is now permitted for these commands.
  698.  
  699. --- 1274,1280 -----
  700.   .B 
  701.   .SM PATH
  702.   variable is changed or the
  703. ! .B hash \-r
  704.   command is executed (see below).
  705.   .SS Special Commands
  706.   Input/output redirection is now permitted for these commands.
  707. ***************
  708. *** 1028,1034
  709.   .br
  710.   .ne 2.1v
  711.   .TP
  712. ! \f3echo\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
  713.   Echo arguments. See
  714.   .IR echo (1) 
  715.   for usage and description.
  716.  
  717. --- 1357,1363 -----
  718.   .br
  719.   .ne 2.1v
  720.   .TP
  721. ! \f3echo\fP \*(OK \f3\-n\fP \*(CK \*(OK \f2arg\^\fP .\|.\|. \*(CK
  722.   Echo arguments. See
  723.   .IR echo (1) 
  724.   for usage and description.
  725. ***************
  726. *** 1032,1037
  727.   Echo arguments. See
  728.   .IR echo (1) 
  729.   for usage and description.
  730.   .TP
  731.   \f3eval\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
  732.   The arguments are read as input
  733.  
  734. --- 1361,1375 -----
  735.   Echo arguments. See
  736.   .IR echo (1) 
  737.   for usage and description.
  738. + The semantics of
  739. + .BR echo ,
  740. + except for the BRL addition of the old-fashioned
  741. + .B \-n
  742. + ``no newline'' option,
  743. + are those of the UNIX System V command;
  744. + in particular,
  745. + .B \e
  746. + escape sequences are processed.
  747.   .TP
  748.   \f3eval\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
  749.   The arguments are read as input
  750. ***************
  751. *** 1088,1093
  752.   adjacent to the \f2hits\fR information.
  753.   \f2Cost\fR will be incremented when the recalculation is done.
  754.   .TP
  755.   \f3newgrp\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
  756.   Equivalent to
  757.   .BI "exec newgrp" " arg\^"
  758.  
  759. --- 1426,1474 -----
  760.   adjacent to the \f2hits\fR information.
  761.   \f2Cost\fR will be incremented when the recalculation is done.
  762.   .TP
  763. + \fBhistory\fP \*(OK \fB\-irs\fP \*(OK \fIfilename\fP \*(CK \*(CK
  764. + The \fBhistory\fP command, with no arguments, will print all the commands that
  765. + are currently saved in the shell's history buffers.  As new commands are
  766. + executed, and space in the buffers runs out, old commands will be deleted.  The
  767. + .B history
  768. + commands prints out the stored commands with sequence numbers.  Negative
  769. + numbered commands, through command number zero, are commands that were
  770. + retrieved from the saved history file.  Commands starting at one were
  771. + entered during the current login session.
  772. + If a saved command contains embedded newlines, these will be printed out
  773. + as the sequence
  774. + .BR \en ,
  775. + so that individual command stay on one line.
  776. + .sp
  777. + The \fBhistory\fP command takes two optional arguments.  If the first
  778. + argument is \fB\-s\fP, the shell will save its current history buffers
  779. + in the file named as the third argument. If no file is given, it will
  780. + use the value of
  781. + .BR \s-1HISTFILE\s+1 .
  782. + .sp
  783. + Similarly, if the first argument is \fB\-r\fP, the shell will reset its
  784. + history buffers from the saved history in the file given as the third argument.
  785. + Again, if no file name is given,
  786. + .B \s-1$HISTFILE\s+1
  787. + will be used.
  788. + .sp
  789. + The command
  790. + .B history -i
  791. + will cause the shell to reinitialize its history buffers.  In other words,
  792. + all the shell's saved history will be thrown away, and the shell will
  793. + start from scratch.
  794. + .sp
  795. + The \fBhistory\fP command will have absolutely no effect at all if input
  796. + is not coming from a terminal.  I.e., inside shell files, the
  797. + .B history
  798. + command is effectively a null operation.
  799. + .sp
  800. + The
  801. + .B history
  802. + command will always have an exit status of 1 inside a shell file.
  803. + If input is coming from a terminal, then the exit status wil be 0
  804. + if the command succeeds, 1 otherwise.
  805. + .TP
  806.   \f3newgrp\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
  807.   Equivalent to
  808.   .BI "exec newgrp" " arg\^"
  809. ***************
  810. *** 1135,1141
  811.   If
  812.   .I n 
  813.   is omitted, the return status is that of the last command executed.
  814. ! .bp
  815.   .TP
  816.   \f3set\fP \*(OK \f3\-\-aefhkntuvx\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK \*(CK
  817.   .RS
  818.  
  819. --- 1516,1522 -----
  820.   If
  821.   .I n 
  822.   is omitted, the return status is that of the last command executed.
  823. ! .\" .bp
  824.   .TP
  825.   \f3set\fP \*(OK \f3\-\-aefhkntuvxEHIJ\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK \*(CK
  826.   .RS
  827. ***************
  828. *** 1137,1143
  829.   is omitted, the return status is that of the last command executed.
  830.   .bp
  831.   .TP
  832. ! \f3set\fP \*(OK \f3\-\-aefhkntuvx\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK \*(CK
  833.   .RS
  834.   .TP
  835.   .B \-a
  836.  
  837. --- 1518,1524 -----
  838.   is omitted, the return status is that of the last command executed.
  839.   .\" .bp
  840.   .TP
  841. ! \f3set\fP \*(OK \f3\-\-aefhkntuvxEHIJ\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK \*(CK
  842.   .RS
  843.   .TP
  844.   .B \-a
  845. ***************
  846. *** 1173,1178
  847.   .B \-x
  848.   Print commands and their arguments as they are executed.
  849.   .TP
  850.   .B \-\-
  851.   Do not change any of the flags; useful in setting
  852.   .B $1
  853.  
  854. --- 1554,1595 -----
  855.   .B \-x
  856.   Print commands and their arguments as they are executed.
  857.   .TP
  858. + .B \-E
  859. + Prevents an EOT
  860. + .RI ( control-D\^ )
  861. + from terminating an interactive shell.
  862. + Added by BRL mostly for use in
  863. + .IR .profile\^ s
  864. + to avoid accidental logout.
  865. + .TP
  866. + .B \-H
  867. + Disable history processing.  If the shell is invoked with this option,
  868. + it will not bother trying to restore its saved history from the
  869. + contents of
  870. + .BR \s-1$HISTFILE\s+1 .
  871. + While this flag is in effect, the shell will not save any commands in
  872. + its history buffers.
  873. + The sequence
  874. + .B %e
  875. + in the value of
  876. + .B \s-1PS1\s+1
  877. + will also have no effect on the generated prompt string.
  878. + If
  879. + .B set +H
  880. + is used to turn history processing back on, the shell will start saving
  881. + subsequent commands from that point on.
  882. + .TP
  883. + .B \-I
  884. + (BRL addition)
  885. + Prints a resource usage summary
  886. + on 4.2BSD
  887. + (system plus user time, blocks input and output, page reclaims and faults)
  888. + for each command after it terminates.
  889. + .TP
  890. + .B \-J
  891. + (BRL addition)
  892. + Enables ``job control'' features (see below).
  893. + .TP
  894.   .B \-\-
  895.   Do not change any of the flags; useful in setting
  896.   .B $1
  897. ***************
  898. *** 1292,1298
  899.   If
  900.   .I nnn\^
  901.   is omitted, the current value of the mask is printed.
  902. ! .bp
  903.   .TP
  904.   \f3unset\fP \*(OK \f2name\^\fP .\|.\|. \*(CK
  905.   For each 
  906.  
  907. --- 1709,1715 -----
  908.   If
  909.   .I nnn\^
  910.   is omitted, the current value of the mask is printed.
  911. ! .\" .bp
  912.   .TP
  913.   \f3unset\fP \*(OK \f2name\^\fP .\|.\|. \*(CK
  914.   For each 
  915. ***************
  916. *** 1321,1326
  917.   and from
  918.   .BR \s-1$HOME\s+1/.profile ,
  919.   if such files exist.
  920.   Thereafter, commands are read as described below, which
  921.   is also the case when the shell is invoked as
  922.   .BR /bin/sh .
  923.  
  924. --- 1738,1755 -----
  925.   and from
  926.   .BR \s-1$HOME\s+1/.profile ,
  927.   if such files exist.
  928. + Next, whether or not the first character of argument zero was a
  929. + .BR \- ,
  930. + and no matter how the shell was invoked,
  931. + the shell will read commands from the file
  932. + .BR \s-1$HOME\s+1/.shrc ,
  933. + if it exists.
  934. + The, if the shell is interactive, is not a forked subshell,
  935. + and the
  936. + .B \-H
  937. + flag is not in effect,
  938. + it will attempt restore its saved history from
  939. + .BR \s-1$HISTFILE\s+1 .
  940.   Thereafter, commands are read as described below, which
  941.   is also the case when the shell is invoked as
  942.   .BR /bin/sh .
  943. ***************
  944. *** 1324,1329
  945.   Thereafter, commands are read as described below, which
  946.   is also the case when the shell is invoked as
  947.   .BR /bin/sh .
  948.   The flags below are interpreted by the shell on invocation only; Note
  949.   that unless the 
  950.   .B \-c
  951.  
  952. --- 1753,1763 -----
  953.   Thereafter, commands are read as described below, which
  954.   is also the case when the shell is invoked as
  955.   .BR /bin/sh .
  956. + If any character of argument zero past the last slash (if any) is
  957. + .BR j ,
  958. + the
  959. + .B \-J
  960. + (job control) flag is automatically set.
  961.   The flags below are interpreted by the shell on invocation only; Note
  962.   that unless the 
  963.   .B \-c
  964. ***************
  965. *** 1372,1377
  966.   If the
  967.   .B \-r
  968.   flag is present the shell is a restricted shell.
  969.   .PD
  970.   .PP
  971.   The remaining flags and arguments are described under the
  972.  
  973. --- 1806,1822 -----
  974.   If the
  975.   .B \-r
  976.   flag is present the shell is a restricted shell.
  977. + .TP
  978. + .B \-q
  979. + If the
  980. + .B \-q
  981. + flag is present, the shell will do a ``quick'' startup.
  982. + This means that the shell will
  983. + .I not
  984. + read the contents of the
  985. + .B \s-1$HOME\s+1/.shrc
  986. + file.
  987. + The shell will also not try to read this file if it is a restricted shell.
  988.   .PD
  989.   .PP
  990.   The remaining flags and arguments are described under the
  991. ***************
  992. *** 1439,1445
  993.   .IR rsh .
  994.   Some systems also provide a restricted editor
  995.   .IR red .
  996. ! .bp
  997.   .SH EXIT STATUS
  998.   Errors detected by the shell, such as syntax errors,
  999.   cause the shell
  1000.  
  1001. --- 1884,1973 -----
  1002.   .IR rsh .
  1003.   Some systems also provide a restricted editor
  1004.   .IR red .
  1005. ! .\" .bp
  1006. ! .SS Job Control
  1007. ! Job control features are enabled by the
  1008. ! .B \-J
  1009. ! flag.
  1010. ! When job control is enabled,
  1011. ! background commands and foreground commands that have been stopped
  1012. ! (usually by a \s-1SIGTSTP\s0 signal generated by typing
  1013. ! .IR ^Z\^ )
  1014. ! are placed into separate individual
  1015. ! .IR "process groups"\^ .
  1016. ! The following commands are used to manipulate these process groups:
  1017. ! .PP
  1018. ! .PD 0
  1019. ! .TP
  1020. ! \f3jobs\fP
  1021. ! Display information about the controlled jobs.
  1022. ! The job number is given in brackets,
  1023. ! followed by a plus sign if it is the ``current job'',
  1024. ! then the process group number for the job,
  1025. ! then the command.
  1026. ! .TP
  1027. ! \f3fg\fP \*(OK \f2n\^\fP \*(CK
  1028. ! Resume the stopped foreground job in the foreground.
  1029. ! If the process group
  1030. ! .I n\^
  1031. ! is not specified then the ``current job'' is resumed.
  1032. ! .TP
  1033. ! \f3bg\fP \*(OK \f2n\^\fP \*(CK
  1034. ! Resume the stopped foreground job in the background.
  1035. ! If the process group
  1036. ! .I n\^
  1037. ! is not specified then the ``current job'' is resumed.
  1038. ! .TP
  1039. ! .B suspend
  1040. ! Suspend the shell process itself in the background.
  1041. ! The shell will complain
  1042. ! if it is a login shell, and will not suspend itself.
  1043. ! Otherwise, it does not matter whether or not job control is enabled.
  1044. ! .PD
  1045. ! .PP
  1046. ! With job control enabled,
  1047. ! there are the following additional substitutable parameters:
  1048. ! .PP
  1049. ! .PD 0
  1050. ! .TP
  1051. ! .BR %%
  1052. ! If there is a ``current job'',
  1053. ! then this expression is replaced by
  1054. ! its process group number.
  1055. ! .TP
  1056. ! .BI % n\^
  1057. ! If the specified job number is one of the known jobs,
  1058. ! then this expression is replaced by
  1059. ! the corresponding process group number.
  1060. ! .SS Saving and Restoring History
  1061. ! When an interactive shell starts up, if the
  1062. ! .B \-H
  1063. ! flag is not in effect, it will attempt to read the contents of
  1064. ! .B \s-1$HISTFILE\s+1
  1065. ! into its history buffers.  This allows the user to recall commands
  1066. ! executed during a previous login session.
  1067. ! When the shell exits or executes an
  1068. ! .B exec
  1069. ! (again, if
  1070. ! .B \-H
  1071. ! is not in effect), it will attempt to write its current history
  1072. ! buffers into
  1073. ! .BR \s-1$HISTFILE\s+1 ,
  1074. ! for use in a future login session.
  1075. ! .PP
  1076. ! The
  1077. ! .B history
  1078. ! command allows the user to save the current history buffers into
  1079. ! a file of his or her own choosing, or to restore them from a given file.
  1080. ! If
  1081. ! .B \-H
  1082. ! has been set, the
  1083. ! .B history
  1084. ! command will give a warning that history processing is not
  1085. ! available, and will
  1086. ! .I not
  1087. ! save or restore the shell's history buffers.
  1088. ! .PD
  1089.   .SH EXIT STATUS
  1090.   Errors detected by the shell, such as syntax errors,
  1091.   cause the shell
  1092. ***************
  1093. *** 1455,1460
  1094.   .br
  1095.   \s-1$HOME\s+1/\f3.\fPprofile
  1096.   .br
  1097.   /tmp/sh\(**
  1098.   .br
  1099.   /dev/null
  1100.  
  1101. --- 1983,1990 -----
  1102.   .br
  1103.   \s-1$HOME\s+1/\f3.\fPprofile
  1104.   .br
  1105. + \s-1$HOME\s+1/\f3.\fPshrc
  1106. + .br
  1107.   /tmp/sh\(**
  1108.   .br
  1109.   /dev/null
  1110. ***************
  1111. *** 1462,1467
  1112.   acctcom(1),
  1113.   cd(1),
  1114.   echo(1),
  1115.   env(1),
  1116.   login(1),
  1117.   newgrp(1),
  1118.  
  1119. --- 1992,1998 -----
  1120.   acctcom(1),
  1121.   cd(1),
  1122.   echo(1),
  1123. + ed(1),
  1124.   env(1),
  1125.   login(1),
  1126.   newgrp(1),
  1127. ***************
  1128. *** 1475,1480
  1129.   dup(2),
  1130.   exec(2),
  1131.   fork(2),
  1132.   pipe(2),
  1133.   signal(2),
  1134.   ulimit(2),
  1135.  
  1136. --- 2006,2013 -----
  1137.   dup(2),
  1138.   exec(2),
  1139.   fork(2),
  1140. + getppid(2),
  1141. + getuid(2),
  1142.   pipe(2),
  1143.   signal(2),
  1144.   ulimit(2),
  1145. ***************
  1146. *** 1502,1504
  1147.   .B cd\^
  1148.   command with a full path name
  1149.   to correct this situation.
  1150.  
  1151. --- 2035,2151 -----
  1152.   .B cd\^
  1153.   command with a full path name
  1154.   to correct this situation.
  1155. + .SH PYRAMID SPECIFIC
  1156. + .PP
  1157. + On computers manufactured by the Pyramid Corporation, which support
  1158. + both the University of California at Berkeley 4.2BSD version of \s-1UNIX\s+1,
  1159. + and the AT&T System V version of \s-1UNIX\s+1,
  1160. + the shell has several additional capabilities.
  1161. + .SS Special Commands
  1162. + .PP
  1163. + There are three additional commands built in to the shell. They are:
  1164. + .RS
  1165. + .TP
  1166. + \fBatt\fP \*(OK command \*(CK
  1167. + Switch the current ``universe'' to be ATT System V.
  1168. + If a command is specified, that command will be run in the ``att''
  1169. + universe, without affecting the shell's current universe.
  1170. + The
  1171. + .B \-t
  1172. + option of
  1173. + .B /bin/att
  1174. + is not (yet) supported.
  1175. + .TP
  1176. + \fBucb\fP \*(OK command \*(CK
  1177. + Switch the current ``universe'' to be University of California at
  1178. + Berkeley 4.2BSD.
  1179. + If a command is specified, that command will be run in the ``ucb''
  1180. + universe, without affecting the shell's current universe.
  1181. + The
  1182. + .B \-t
  1183. + option of
  1184. + .B /bin/ucb
  1185. + is not (yet) supported.
  1186. + .TP
  1187. + \fBuniverse\fP \*(OK \fB\-l\fP \*(CK
  1188. + Print the current universe, either ``att'' or ``ucb''. The
  1189. + .B \-l
  1190. + option will print a longer, more explanative name for the current universe.
  1191. + .RE
  1192. + .PP
  1193. + If the shell cannot determine the current universe when it starts up,
  1194. + it will default to
  1195. + .BR ucb .
  1196. + .SS Shell Variables
  1197. + .PP
  1198. + There is an additional pre-defined shell parameter,
  1199. + .BR \s-1UNIVERSE\s+1 .
  1200. + The value of
  1201. + .B \s-1UNIVERSE\s+1
  1202. + .I always
  1203. + tracks that of the current universe.  Using it is equivalent to a
  1204. + \*`universe\` command substitution,
  1205. + except that a new process will not be created.
  1206. + This variable cannot be set by the user (it is \fBreadonly\fP),
  1207. + and any inherited value from the environment will be ignored.
  1208. + .SS Special Sequences for \s-1PS1\s+1
  1209. + .PP
  1210. + Finally, the sequence
  1211. + .B %u
  1212. + in the value of
  1213. + .B \s-1PS1\s-1
  1214. + will cause the shell to subsitute in the name of the current universe,
  1215. + either ``att'' or ``ucb''.
  1216. + .SH HISTORY EXAMPLES
  1217. + Command history provides a powerful method for easily redoing previous
  1218. + commands, or for quicly fixing typing mistakes.
  1219. + Here are some annotated examples.  User input is in
  1220. + .BR boldface .
  1221. + .sp
  1222. + .nf
  1223. + # first, list some files
  1224. + .RB "$ " lf
  1225. + hello.c        echo.c
  1226. + # now, make a typing mistake
  1227. + .RB "$ " "cat hello"
  1228. + hello: No such file or directory
  1229. + # fix it.  The trailing ! ends the history substitution,
  1230. + # in order to correctly concatenate it with the following .c
  1231. + .RB "$ " "!!.c"
  1232. + cat hello.c
  1233. + main () { printf ("hello world\en"); }
  1234. + # now look at echo.c instead
  1235. + .RB "$ " "!^hello^echo"
  1236. + cat echo.c
  1237. + main () { printf ("echo: no arguments\en"); }
  1238. + # do it again, just for fun
  1239. + .RB "$ " "!"
  1240. + cat echo.c
  1241. + main () { printf ("echo: no arguments\en"); }
  1242. + # now we'll rearrange some arguments
  1243. + .RB "$ " "echo 1 2 3 4 5"
  1244. + 1 2 3 4 5
  1245. + # print last argument, first and second arguments, then change 4 to four
  1246. + .RB "$ " "echo !\(ga$ !\(ga1-2 !\(ga4^4^four"
  1247. + echo 5 1 2 four
  1248. + 5 1 2 four
  1249. + # do something with all the previous arguments at once
  1250. + .RB "$ " "echo the previous arguments were !\(ga\-"
  1251. + echo the previous arguments were 5 1 2 four
  1252. + the previous arguments were 5 1 2 four
  1253. + # now do some substitutions.  first get something to work with.
  1254. + .RB "$ " "echo aa bb cc"
  1255. + aa bb cc
  1256. + # change the first 'a' to a 'b', and change all c's to d's
  1257. + .RB "$ " "!^a^b^^c^d^g"
  1258. + echo ba bb dd
  1259. + ba bb dd
  1260. + .fi
  1261. + .PP
  1262. + These few brief examples should provide a general feel for the
  1263. + history mechanism.  The quickest way to learn it is to experiment
  1264. + with it for a while, using the
  1265. + .B echo
  1266. + command, which can do very little damage.
  1267. + While it looks cryptic when being typed, it is very general and
  1268. + orthogonal, and quickly becomes natural.
  1269.  
  1270.