commit bc11ebf09feec23608459c8e632f30369c6bae49
parent 2ef8a59ae61b83ad2ba9d4c9381eead5ae403cb0
Author: Toby Goodwin <tjg@star.le.ac.uk>
Date: Tue, 20 Nov 2001 16:01:03 +0000
candidate: rc-1.6c5
Diffstat:
14 files changed, 145 insertions(+), 56 deletions(-)
diff --git a/AUTHORS b/AUTHORS
@@ -28,10 +28,10 @@ version of rc presented here differs in some respects.
Tim would like to thank these people for their contributions since he
took over maintenance of rc. Aharon Robbins, Arvid Requate, Bengt
-Kleberg, Brynjulv Hauksson, Byron Rakitzis, Chris Siebenmann, Dale
-Scheetz, David Luyer, David Swasey, Decklin Foster, Donn Cave, Gary
-Carvell, Gerry Tomlinson, Gert-Jan Vons, Ian Lance Taylor, Jeremy
-Fitzhardinge, Marc Moorcroft, Mark H Wilkinson, Mark K Gardner,
-Raymond Venneker, Rich $alz, Rob Savoye, Scott Schwartz, Stefan
-Dalibor, Steve Simon, Thomas Nordin, Tom Culliton, Tom Tromey, Vincent
-Broman, Wolfgang Zekoll.
+Kleberg, Brynjulv Hauksson, Byron Rakitzis, Callum Gibson, Chris
+Siebenmann, Dale Scheetz, David Luyer, David Swasey, Decklin Foster,
+Donn Cave, Gary Carvell, Gerry Tomlinson, Gert-Jan Vons, Ian Lance
+Taylor, Jeremy Fitzhardinge, Marc Moorcroft, Mark H Wilkinson, Mark K
+Gardner, Raymond Venneker, Rich $alz, Rob Savoye, Scott Schwartz,
+Stefan Dalibor, Steve Simon, Thomas Nordin, Tom Culliton, Tom Tromey,
+Vincent Broman, Wolfgang Zekoll.
diff --git a/ChangeLog b/ChangeLog
@@ -739,3 +739,21 @@ Changes since rc-1.5b2
Documentation: subscripted variables don't work in here documents.
Release: rc-1.6c4.
+
+2001-11-01
+
+ Bug: more wrongly ordered header file includes (thanks Callum
+ Gibson).
+
+2001-11-06
+
+ Portability: rename print.c::utoa() to rc_utoa() to avoid QNX name
+ clash; use "sh -c 'test ...'" in trip.rc for missing standalone
+ `test' on QNX (thanks Stefan Dalibor).
+
+2001-11-20
+
+ Documentation: tighten up various descriptions, and include some
+ more examples.
+
+ Release: rc-1.6c5.
diff --git a/README b/README
@@ -1,4 +1,4 @@
-This is beta release rc-1.6b3.
+This is release candidate rc-1.6c5.
See COPYING for copying information. All files are
diff --git a/configure.ac b/configure.ac
@@ -8,7 +8,7 @@ dnl Automake stuff.
dnl Use this one for snapshots...
dnl AM_INIT_AUTOMAKE(rc, 1.6s`echo $RELDATE |sed 's/-//g'`)
dnl ...and this one for releases
-AM_INIT_AUTOMAKE(rc, 1.6c4)
+AM_INIT_AUTOMAKE(rc, 1.6c5)
AM_CONFIG_HEADER(config.h)
diff --git a/except.c b/except.c
@@ -1,6 +1,8 @@
+#include "rc.h"
+
#include <setjmp.h>
#include <signal.h>
-#include "rc.h"
+
#include "jbwrap.h"
/*
diff --git a/exec.c b/exec.c
@@ -1,7 +1,12 @@
/* exec.c */
+
+#include "rc.h"
+
#include <errno.h>
#include <signal.h>
+#include "wait.h"
+
#include "rc.h"
#include "wait.h"
/*
diff --git a/fn.c b/fn.c
@@ -3,9 +3,11 @@
Support for signal handlers is also found here.
*/
+#include "rc.h"
+
#include <signal.h>
#include <errno.h>
-#include "rc.h"
+
#include "sigmsgs.h"
static void fn_handler(int), dud_handler(int);
diff --git a/parse.y b/parse.y
@@ -5,6 +5,8 @@
*/
%{
+/* note that this actually needs to appear before any system header
+ files are included; byacc likes to throw in <stdlib.h> first. */
#include "rc.h"
static Node *star, *nolist;
diff --git a/print.c b/print.c
@@ -69,9 +69,9 @@ static bool sconv(Format *format, int ignore) {
return FALSE;
}
-static char *utoa(unsigned long u, char *t, unsigned int radix, const char *digit) {
+static char *rc_utoa(unsigned long u, char *t, unsigned int radix, const char *digit) {
if (u >= radix) {
- t = utoa(u / radix, t, radix, digit);
+ t = rc_utoa(u / radix, t, radix, digit);
u %= radix;
}
*t++ = digit[u];
@@ -117,7 +117,7 @@ static void intconv(Format *format, unsigned int radix, int upper, const char *a
while (*altform != '\0')
prefix[pre++] = *altform++;
- len = utoa(u, number, radix, table[upper]) - number;
+ len = rc_utoa(u, number, radix, table[upper]) - number;
if ((flags & FMT_f2set) && (size_t) format->f2 > len)
zeroes = format->f2 - len;
else
diff --git a/rc.1 b/rc.1
@@ -32,15 +32,15 @@
.\" for pointing out these problems.
.\"
.\" Note that sentences should end at the end of a line. nroff and
-.\" troff will supply the correct intersentence spacing, but only if
+.\" troff will supply the correct inter-sentence spacing, but only if
.\" the sentences end at the end of a line. Explicit spaces, if given,
-.\" are apparently honored and the normal intersentence spacing is
+.\" are apparently honored and the normal inter-sentence spacing is
.\" suppressed.
.\"
.\" DaviD W. Sanderson
.\"-------
.\" Dd distance to space vertically before a "display"
-.\" These are what n/troff use for interparagraph distance
+.\" These are what n/troff use for inter-paragraph distance
.\"-------
.if t .nr Dd .4v
.if n .nr Dd 1v
@@ -161,7 +161,7 @@
.if !"\\$4"" .Xf \\$2 \\$1 "\\$3\\f\\$1\\$4\\*(Xi" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
.if "\\$4"" \\$3\fR\s10
..
-.TH RC 1 "2001-10-31"
+.TH RC 1 "2001-11-20"
.SH NAME
rc \- shell
.SH SYNOPSIS
@@ -700,9 +700,7 @@ is omitted, then
will set
.I var
to each element of
-.Cr $*
-(excluding
-.Cr $0 ).
+.Cr $* .
For example:
.Ds
.Cr "for (i in \`{ls -F | grep '\e*$' | sed 's/\e*$//'}) { commands }"
@@ -876,7 +874,7 @@ Thus, the command
.PP
returns true if any of the files in the current directory have a
single-character name.
-(Note that if the
+If the
.Cr ~
command is given a list as its first
argument, then a successful match against any of the elements of that
@@ -888,7 +886,7 @@ For example:
.Cr "~ (foo goo zoo) z*"
.De
.PP
-is true.)
+is true.
.SH "LISTS AND VARIABLES"
The primary data structure in
.IR rc
@@ -926,18 +924,7 @@ produces the output
.SS "List Concatenation"
Two lists may be joined by the concatenation operator
.Rc ( ^ ).
-A single word is treated as a list of length one, so
-.Ds
-.Cr "echo foo^bar"
-.De
-.PP
-produces the output
-.Ds
-.Cr foobar
-.De
-.PP
-For lists of more than one element,
-concatenation works according to the following rules:
+Concatenation works according to the following rules:
if the two lists have the same number of elements,
then concatenation is pairwise:
.Ds
@@ -949,7 +936,7 @@ produces the output
.Cr "a\-1 b\-2 c\-3"
.De
.PP
-Otherwise, one of the lists must have a single element,
+Otherwise, at least one of the lists must have a single element,
and then the concatenation is distributive:
.Ds
.Cr "cc \-^(O g c) (malloc alloca)^.c"
@@ -959,6 +946,16 @@ has the effect of performing the command
.Ds
.Cr "cc \-O \-g \-c malloc.c alloca.c"
.De
+.PP
+A single word is a list of length one, so
+.Ds
+.Cr "echo foo^bar"
+.De
+.PP
+produces the output
+.Ds
+.Cr foobar
+.De
.SS "Free Carets"
.I rc
inserts carets (concatenation operators) for free in certain situations,
@@ -1214,6 +1211,8 @@ etc. are the same as
.Cr $*(1) ,
.Cr $*(2) ,
etc.
+.TP
+.Cr 0
The variable
.Cr $0
holds the value of
@@ -1230,13 +1229,49 @@ is also set to the name of the
file being interpreted for the duration of a
.Cr .
command.
+.Cr $0
+is not an element of
+.Cr $* ,
+and is never treated as one.
.TP
.Cr apid
The process ID of the last process started in the background.
.TP
.Cr apids " (read only)"
-The process IDs of any background processes which are outstanding
-or which have died and have not been waited for yet.
+A list whose elements are the process IDs of all background processes
+which are still alive, or which have died and have not been waited for
+yet.
+.TP
+.Cr bqstatus
+The exit status of the
+.I rc
+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:
+.Ds
+.Cr "echo foo |grep bar; whatis status"
+.De
+.TP
+\&
+prints
+.Ds
+.Cr "status=(0 1)"
+.De
+.TP
+\&
+whereas
+.Ds
+.Cr "x=`{echo foo |grep bar}; whatis bqstatus"
+.De
+.TP
+\&
+prints
+.Ds
+.Cr "bqstatus=1"
+.De
.TP
.Cr bqstatus
The exit status of the
@@ -1282,8 +1317,7 @@ does not append commands to any file.
.Cr home
The default directory for the builtin
.B cd
-command and is the directory
-in which
+command, and the directory in which
.I rc
looks to find its initialization file,
.Cr .rcrc ,
@@ -1364,7 +1398,7 @@ directly into a file for use as a shell script, without further editing
being necessary.
.TP
.Cr prompt " (function)"
-If this function is set, then it gets executed every time
+If this function is defined, then it gets executed every time
.I rc
is about to print
.Cr "$prompt(1)" .
@@ -1391,9 +1425,13 @@ to
.Cr "(0 0)" .
.TP
.Cr version " (read only)"
-This variable contains a string which identifies this
+The first element of this list variable is a string which identifies this
version of
.IR rc .
+The second element is a string which can be found by
+.IR ident
+and
+.IR "sccs what" .
.PP
The values of
.Cr "$path" ,
@@ -1568,6 +1606,22 @@ Executes the command ignoring any function definition of the
same name.
This command is present to allow functions with the
same names as builtins to use the underlying builtin or binary.
+For example:
+.Ds
+.Cr "fn ls { builtin ls -FC $* }"
+.De
+.TP
+\&
+is a reasonable way to pass a default set of arguments to
+.Cr ls (1).
+.Ds
+.Cr "fn ls { ls -FC $* }"
+.De
+.TP
+\&
+is a non-terminating recursion, which will cause
+.Cr rc
+to exhaust its stack space and (eventually) terminate if it is executed.
.TP
\fBcd \fR[\fIdirectory\fR]
Changes the current directory to
@@ -1671,7 +1725,7 @@ Returns from the current function, with status
.IR n ,
where
.IR n
-is a single value or a list of possible exit statuses.
+is a valid exit status, or a list of them.
Thus it is legal to have
.Ds
.Cr "return (sigpipe 1 2 3)"
@@ -1699,10 +1753,6 @@ elements down by
.IR n .
.I n
defaults to 1.
-(Note that
-.Cr $0
-is not affected by
-.BR shift .)
.TP
\fBumask \fR[\fImask\fR]
Sets the current umask (see
@@ -1712,15 +1762,16 @@ to the octal
If no argument is present, the current mask value is printed.
.TP
\fBwait \fR[\fIpid\fR]
-Waits for the specified
+Waits for process with the specified
.IR pid ,
which must have been started by
-.IR rc .
+.IR rc ,
+to exit.
If no
.I pid
is specified,
.I rc
-waits for all child processes to exit.
+waits for all its child processes to exit.
.TP
\fBwhatis \fR[\fB\-b\fR] \fR[\fB\-f\fR] \fR[\fB\-p\fR] \fR[\fB\-s\fR] \fR[\fB\-v\fR] [\fB\-\|\-\fR] [\fIname ...\fR]
Prints a definition of the named objects.
@@ -1823,7 +1874,7 @@ This function allows the separator to be an arbitrary string.
With this definition in place,
.Ds
.Cr "hops=(uunet mcvax ukc tlg)"
-.Cr lflat hops !
+.Cr "lflat hops !"
.De
.PP
prints (with no final newline)
@@ -1984,8 +2035,12 @@ doesn't use systems which lack
any more.
If anybody can reproduce this problem, please let the maintainer know.)
.PP
+The
.B echo
-is built in only for performance reasons, which is a bad idea.
+command does not need to be a builtin. It is one for reasons of
+performance and portability (of
+.I rc
+scripts).
.PP
There should be a way to avoid exporting a variable.
.PP
diff --git a/signal.c b/signal.c
@@ -1,9 +1,10 @@
/* signal.c: a Hugh-approved signal handler. */
+#include "rc.h"
+
#include <signal.h>
#include <setjmp.h>
-#include "rc.h"
#include "sigmsgs.h"
#include "jbwrap.h"
diff --git a/trip.rc b/trip.rc
@@ -352,7 +352,7 @@ if (~ x [y])
if (~ x x?)
fail too many characters in pattern
-test -f /////tmp//////a?c.$pid || fail glob with many slashes
+sh -c 'test -f /////tmp//////a?c.'^$pid || fail glob with many slashes
if (!~ /////tmp//////a*.$pid /////tmp//////a?c.$pid)
fail glob with many slashes
if (!~ ////tmp////di?.$pid////* ////tmp////dir.$pid////*b*)
diff --git a/utils.c b/utils.c
@@ -1,8 +1,10 @@
/* utils.c: functions of general utility */
+#include "rc.h"
+
#include <errno.h>
#include <setjmp.h>
-#include "rc.h"
+
#include "jbwrap.h"
/* print error with line number on noninteractive shells (i.e., scripts) */
diff --git a/walk.c b/walk.c
@@ -1,8 +1,10 @@
/* walk.c: walks the parse tree. */
+#include "rc.h"
+
#include <signal.h>
#include <setjmp.h>
-#include "rc.h"
+
#include "jbwrap.h"
/*