PR/2808: Add HISTORY section and documentation of getopts. (from FreeBSD)

This commit is contained in:
christos 1996-10-16 15:20:01 +00:00
parent da8c1311a3
commit 3b66e0cada
1 changed files with 30 additions and 17 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: sh.1,v 1.16 1996/09/02 21:28:21 christos Exp $
.\" $NetBSD: sh.1,v 1.17 1996/10/16 15:20:01 christos Exp $
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@ -347,33 +347,33 @@ previously. Following is a list of the possible redirections.
The [n] is an optional number, as in '3' (not '[3]'), that
refers to a file descriptor.
.TP
[n]> file
[n]> file
Redirect standard output (or n) to file.
.TP
[n]>| file
[n]>| file
Same, but override the -C option.
.TP
[n]>> file
[n]>> file
Append standard output (or n) to file.
.TP
[n]< file
[n]< file
Redirect standard input (or n) from file.
.TP
[n1]<&n2
[n1]<&n2
Duplicate standard input (or n1) from
file descriptor n2.
.TP
[n]<&-
[n]<&-
Close standard input (or n).
.TP
[n1]>&n2
[n1]>&n2
Duplicate standard output (or n) from
n2.
.TP
[n]>&-
[n]>&-
Close standard output (or n).
.TP
[n]<> file
[n]<> file
Open file for reading and writing on
standard input (or n).
.LP
@ -834,7 +834,7 @@ The $ character is used to introduce parameter expansion, command
substitution, or arithmetic evaluation.
.sp 2
.B Tilde Expansion (substituting a user's home directory)
.sp
.sp
.LP
A word beginning with an unquoted tilde character (~) is
subjected to tilde expansion. All the characters up to
@ -938,7 +938,6 @@ is expanded to produce a pattern. The
parameter expansion then results in
parameter, with the smallest portion of the
suffix matched by the pattern deleted.
.TP
${parameter%%word}
Remove Largest Suffix Pattern. The word
@ -1046,7 +1045,7 @@ Pathname Expansion and the case(1) command.
A pattern consists of normal characters, which match themselves,
and meta-characters. The meta-characters are
``!'', ``*'', ``?'', and ``[''. These characters lose
there special meanings if they are quoted. When command
their special meanings if they are quoted. When command
or variable substitution is performed and the dollar sign
or back quotes are not double quoted, the value of the
variable or the output of the command is scanned for these
@ -1222,6 +1221,14 @@ foreground.
.TP
getopts optstring var
The POSIX getopts command.
The getopts command deprecates the older getopt command.
The first argument should be a series of letters, each possibly
followed by a colon which indicates that the option takes an argument.
The specified variable is set to the parsed option. The index of
the next argument is placed into the shell variable OPTIND.
If an option takes an argument, it is placed into the shell variable
OPTARG. If an invalid option is encountered, var is set to '?'.
It returns a false value (1) when it encounters the end of the options.
.TP
hash -rv command...
The shell maintains a hash table which remembers the
@ -1231,8 +1238,8 @@ table. Entries which have not been looked at since
the last cd command are marked with an asterisk; it
is possible for these entries to be invalid.
.sp
With arguments, the hash command removes the specified
commands from the hash table (unless they are
With arguments, the hash command removes the specified commands
from the hash table (unless they are
functions) and then locates them. With the -v
option, hash prints the locations of the commands as
it finds them. The -r option causes the hash command
@ -1331,8 +1338,8 @@ default action. The trap command has no effect on
signals that were ignored on entry to the shell.
.TP
umask [ mask ]
Set the value of umask (see umask(2)) to the specified octal value.
If the argument is omitted, the
Set the value of umask (see umask(2)) to the specified
octal value. If the argument is omitted, the
umask value is printed.
.TP
unalias [-a] [name]
@ -1366,3 +1373,9 @@ mode. The editor is not described in full here, but will be in a later
document. It's similar to vi: typing <ESC> will throw you into
command VI command mode. Hitting <return> while in command mode
will pass the line to the shell.
.SH HISTORY
A
.I sh
command appeared in
Version 1 AT&T UNIX.
It was, however, unmaintainable so we wrote this one.