summaryrefslogtreecommitdiff
path: root/rc.1
diff options
context:
space:
mode:
Diffstat (limited to 'rc.1')
-rw-r--r--rc.1162
1 files changed, 119 insertions, 43 deletions
diff --git a/rc.1 b/rc.1
index 82ed3ef..b2e7c52 100644
--- a/rc.1
+++ b/rc.1
@@ -11,7 +11,7 @@
.\" man page must contain '\en'.)
.\"
.\" Evidently not all versions of nroff allow the omission of the
-.\" terminal " on a macro argument. Thus what could be written
+.\" terminal " on a macro argument. Thus what could be written
.\"
.\" .Cr "exec >[2] err.out
.\"
@@ -22,7 +22,7 @@
.\" instead.
.\"
.\" Use symbolic font names (e.g. R, I, B) instead of the standard
-.\" font positions 1, 2, 3. Note that for Xf to work the standard
+.\" font positions 1, 2, 3. Note that for Xf to work the standard
.\" font names must be single characters.
.\"
.\" Not all man macros have the RS and RE requests (I altered the Ds
@@ -31,9 +31,9 @@
.\" Thanks to Michael Haardt (u31b3hs@cip-s01.informatik.rwth-aachen.de)
.\" for pointing out these problems.
.\"
-.\" Note that sentences should end at the end of a line. nroff and
+.\" Note that sentences should end at the end of a line. nroff and
.\" troff will supply the correct inter-sentence spacing, but only if
-.\" the sentences end at the end of a line. Explicit spaces, if given,
+.\" the sentences end at the end of a line. Explicit spaces, if given,
.\" are apparently honored and the normal inter-sentence spacing is
.\" suppressed.
.\"
@@ -125,8 +125,8 @@
.\" with a new word made of the current word (\$3) and \$4
.\" rendered in the first font,
.\" and with the remaining args following \$4.
-.\" else We are done recursing. \$3 holds the desired output
-.\" word. We emit \$3, change to Roman font, and restore
+.\" else We are done recursing. \$3 holds the desired output
+.\" word. We emit \$3, change to Roman font, and restore
.\" the point size to the default.
.\" fi
.\"
@@ -136,7 +136,7 @@
.ds Xi
.\"-------
.\" I used to test for the italic font both by its font position
-.\" and its name. Now just test by its name.
+.\" and its name. Now just test by its name.
.\"
.\" .if "\\$1"2" .if !"\\$5"" .ds Xi \^
.\"-------
@@ -222,11 +222,17 @@ If the
.Cr \-e
flag is present, then
.I rc
-will exit if the exit status of a command is false (nonzero).
-.I rc
-will not exit, however, if a conditional fails, e.g., an
-.Cr if()
-command.
+will exit if any command fails (exits with non-zero status). However
+.I "rc -e"
+does not exit if a conditional fails. A conditional is the test of an
+.Cr "if ()"
+command, the test of a
+.Cr "while ()"
+command, or the left hand side of the
+.Cr ||
+or the
+.Cr &&
+operator.
.TP
.Cr \-i
If the
@@ -393,7 +399,7 @@ interprets several characters specially; special characters
automatically terminate words.
The following characters are special:
.Ds
-.Cr "# ; & | ^ $ = \` ' { } ( ) < >"
+.Cr "# ; & | ^ $ \` ' { } ( ) < >"
.De
.PP
The single quote
@@ -653,7 +659,7 @@ The following may be used for control flow in
.sp
.Ci "if (" test ") {"
.br
-.I " cmd"
+.I " cmd"
.br
.TP
.Ci "} else " cmd
@@ -823,22 +829,26 @@ command:
.Cr "~ subject pattern pattern ..."
.De
.PP
+The
.Cr ~
-sets
+command succeeds (sets
.Cr $status
-to zero if and only if a supplied pattern matches any
-single element of the subject list.
+to zero) if and only if one of the
+.Cr pattern s
+matches
+.Cr subject .
Thus
.Ds
.Cr "~ foo f*"
.De
.PP
-sets status to zero, while
+succeeds (sets status to zero), while
.Ds
-.Cr "~ (bar baz) f*"
+.Cr "~ bar f*"
.De
.PP
-sets status to one.
+fails (sets status to one).
+.PP
The null list is matched by the null list, so
.Ds
.Cr "~ $foo ()"
@@ -846,9 +856,30 @@ The null list is matched by the null list, so
.PP
checks to see whether
.Cr $foo
-is empty or not.
-This may also be achieved
-by the test
+is empty or not. Because
+.I rc
+does not have hierarchical lists, the test for emptiness cannot be
+combined with other tests. To test whether
+.Cr $foo
+is empty, or one of the strings
+.Cr nada
+or
+.Cr rien ,
+do
+.I not
+write
+.Ds
+.Cr "~ $x () nada rien # WRONG means the same as: ~ $x nada rien"
+.De
+.PP
+instead write
+.Ds
+.Cr "~ $x () || ~ $x nada rien"
+.De
+.PP
+Another way to test if
+.Cr $foo
+is empty is
.Ds
.Cr "~ $#foo 0"
.De
@@ -872,15 +903,16 @@ Thus, the command
.Cr "~ * ?"
.De
.PP
-returns true if any of the files in the current directory have a
+succeeds if any of the files in the current directory have a
single-character name.
+.PP
If the
.Cr ~
command is given a list as its first
argument, then a successful match against any of the elements of that
list will cause
.Cr ~
-to return true.
+to succeed.
For example:
.Ds
.Cr "~ (foo goo zoo) z*"
@@ -967,7 +999,7 @@ example, the above example could also be typed in as:
.De
.PP
.I rc
-takes care to insert a free-caret between the
+takes care to insert a free caret between the
.Rc `` \- ''
and
.Cr "$opts" ,
@@ -976,7 +1008,7 @@ as between
.Cr $files
and
.Cr ".c" .
-The rule for free carets is as follows: if
+The rule for free carets is as follows: if
a word or keyword is immediately
followed by another word, keyword, dollar-sign or
backquote, then
@@ -1281,12 +1313,12 @@ yet.
.Cr bqstatus " (no-export)"
The exit status of the
.I rc
-forked to execute the most recent backquote substitution. Note that, unlike
+forked to execute the most recent backquote substitution. Note that, unlike
.Cr $status ,
.Cr $bqstatus
is always a single element list (see
.BR "EXIT STATUS"
-below). For example:
+below). For example:
.Ds
.Cr "echo foo |grep bar; whatis status"
.De
@@ -1350,7 +1382,7 @@ has been started up as a login shell.
.TP
.Cr ifs " (default)"
The internal field separator, used for splitting up the output of
-backquote commands for digestion as a list. On startup,
+backquote commands for digestion as a list. On startup,
.I rc
assigns the list containing the characters space, tab, and newline to
.Cr $ifs .
@@ -1400,7 +1432,7 @@ prompt is simply ignored by
The null
.Cr $prompt(2)
also has its
-justification: an
+justification: an
.I rc
script, when typed interactively, will not leave
.Cr $prompt(2) 's
@@ -1841,9 +1873,9 @@ The
builtin only shifts
.Cr "$*" .
This function can shift any variable (except
-.Cr "$lshift" ).
+.Cr "$_lshift" ).
.Ds
-.Cr "fn lshift { lshift=$*; *=$$1; shift $lshift(2); $lshift(1)=$* }"
+.Cr "fn lshift { _lshift=$* *=$$1 { shift $_lshift(2); $_lshift(1)=$* } }"
.De
.PP
With this definition in place,
@@ -1899,6 +1931,45 @@ if every command in the pipeline did; otherwise it exits
can be made to exit with a particular status using the
.B exit
builtin.
+.SH "LINE EDITING"
+.I rc
+is typically built against a line editing library.
+On GNU/Linux systems this will usually be the GNU
+.I readline
+library.
+On *BSD systems it is more likely to be the BSD
+.I editline
+library.
+Please consult the appropriate library documentation for details of how to use
+and configure line editing.
+.SS "Tilde Expansion"
+Since
+.I rc
+does not support tilde expansion (converting
+.Cr ~foo
+to the home directory of user
+.Cr foo ),
+it is sometimes suggested by users as a
+possible enhancement.
+The authors and maintainers of
+.I rc
+have a proud history of resisting such feature requests.
+So it is worth noting here that GNU
+.I readline
+can expand tildes.
+Add this line to the file
+.Cr .inputrc
+in your home directory.
+.Ds
+.Cr "set expand-tilde on"
+.De
+.PP
+and then use the key sequence
+.Cr "M-~"
+to perform tilde expansion on the current word.
+See the
+.I readline
+documentation for further details.
.SH GRAMMAR
Here is
.IR rc 's
@@ -1908,6 +1979,7 @@ grammar, edited to remove semantic actions.
%term ANDAND BACKBACK BANG CASE COUNT DUP ELSE END FLAT FN FOR IF IN
%term OROR PIPE REDIR SUB SUBSHELL SWITCH TWIDDLE WHILE WORD HUH
+%left '^' '='
%left WHILE ')' ELSE
%left ANDAND OROR '\en'
%left BANG SUBSHELL
@@ -1936,7 +2008,7 @@ brace: '{' body '}'
paren: '(' body ')'
-assign: first '=' word
+assign: first optcaret '=' optcaret word
epilog: /* empty */ | redir epilog
@@ -1968,9 +2040,13 @@ cmd : /* empty */ %prec WHILE
| FN words brace
| FN words
-optcaret: /* empty */ | '^'
+optcaret: /* empty */ %prec '^' | '^'
+
+simple: first | first args
-simple: first | simple word | simple redir
+args: arg | args arg
+
+arg: word | redir
first: comword | first '^' sword
@@ -1990,7 +2066,7 @@ comword: '$' sword
| WORD
keyword: FOR | IN | WHILE | IF | SWITCH
- | FN | ELSE | CASE | TWIDDLE | BANG | SUBSHELL
+ | FN | ELSE | CASE | TWIDDLE | BANG | SUBSHELL | '='
words: /* empty */ | words word
@@ -2039,7 +2115,7 @@ If anybody can reproduce this problem, please let the maintainer know.)
.PP
The
.B echo
-command does not need to be a builtin. It is one for reasons of
+command does not need to be a builtin. It is one for reasons of
performance and portability (of
.I rc
scripts).
@@ -2140,12 +2216,12 @@ the
and
.Cr version
variables,
-the support for the GNU
-.IR readline (3)
-library,
-and the support for the
+the
.Cr prompt
-function.
+function,
+support for GNU
+.IR readline
+and other line editing libraries.
This
.I rc
also sets