rc

[fork] interactive rc shell
Log | Files | Refs | README | LICENSE

commit 2ef8a59ae61b83ad2ba9d4c9381eead5ae403cb0
parent 609a278bf6e301ea9a021793de314ddcadb806ba
Author: Toby Goodwin <tjg@star.le.ac.uk>
Date:   Wed, 31 Oct 2001 12:31:57 +0000

candidate: rc-1.6c4

Diffstat:
MAUTHORS | 11++++++-----
MChangeLog | 16++++++++++++++++
MINSTALL | 22++++++++++++++++++++++
MMakefile.am | 4++--
Mconfigure.ac | 4+++-
Minput.c | 4----
Mrc.1 | 129++++++++++++++++++++++++++++++++-----------------------------------------------
Mrc.h | 4++--
Mtrip.rc | 12++++++++++++
Mtripping.c | 23+++++++++++++++++++++++
10 files changed, 138 insertions(+), 91 deletions(-)

diff --git a/AUTHORS b/AUTHORS @@ -29,8 +29,9 @@ 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, 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. +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 @@ -723,3 +723,19 @@ Changes since rc-1.5b2 2001-10-12 Release: rc-1.6b3. + +2001-10-25 + + Feature: large file support (thanks Scott Schwartz, Chris + Siebenmann). + +2001-10-29 + + Bug: space vs tab confusion in commented out Makefile rules to + rebuild parser (thanks Gary Carvell). + +2001-10-31 + + Documentation: subscripted variables don't work in here documents. + + Release: rc-1.6c4. diff --git a/INSTALL b/INSTALL @@ -11,6 +11,7 @@ need to configure, build, test, and install rc. This will build rc in the source directory (see below for details on how to build rc in a different directory). + BUILD AND CONFIGURATION OPTIONS There are lots of options you can give to configure to modify rc's @@ -134,6 +135,25 @@ do this. This will produce some output, and should end with "trip is complete". If the trip instead ends with "trip took a wrong turn..." please contact the maintainer. + +LARGE FILE SUPPORT + +This release of rc supports large files (i.e. with 64 bit offsets), on +systems where the configure script can figure out how to enable this. +When you run `make trip' (you always run `make trip', right?) the +penultimate line of output (before "trip complete") reports whether +large file support seems to be working or not. + +Large file support is a function of file systems, as well as +applications. For example, NFS and tmpfs file systems often do not +support large files. The test used by `make trip' is therefore +subject to false negatives. That is, a report that "large file +support seems NOT to be working" may be erroneous. To minimise this +possibility, the test is performed both in the current directory +(where you built rc) and /tmp. (I don't think there's any scenario +where a false positive can be reported.) + + BUILDING IN ANOTHER DIRECTORY If you have a suitable `make', you can build rc in a different directory @@ -142,6 +162,7 @@ are building rc for multiple architectures. All you need do is specify the path to the configure script in the first step. Suitable `make's include GNU, HP-UX, and SunOS, but not Irix, nor Ultrix, nor UnixWare. + COMPILATION WARNINGS If your C compiler is gcc, the option `-Wall' is turned on. This may @@ -162,6 +183,7 @@ incorrect declaration of `getgroups()' in those systems' header files. Any other warnings should be reported to the maintainer. + OLD C rc needs an ISO C (89) compiler, or at least one that has a reasonable diff --git a/Makefile.am b/Makefile.am @@ -58,8 +58,8 @@ DISTCLEANFILES = sigmsgs.c sigmsgs.h statval.h # portable (I hope). #parse.c parse.h: $(srcdir)/parse.y # $(YACC) -d $(srcdir)/parse.y -# mv y.tab.c parse.c -# mv y.tab.h parse.h +# mv y.tab.c parse.c +# mv y.tab.h parse.h check: trip 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.6b3) +AM_INIT_AUTOMAKE(rc, 1.6c4) AM_CONFIG_HEADER(config.h) @@ -24,6 +24,8 @@ case "$GCC" in yes) CFLAGS="-Wall $CFLAGS" ;; esac +AC_SYS_LARGEFILE + AC_PROG_CPP AC_CHECK_PROGS(LN, ln cp) diff --git a/input.c b/input.c @@ -44,10 +44,6 @@ int lastchar; static char *rlinebuf, *prompt; #endif -#if EDITLINE || READLINE -static char *rlinebuf, *prompt; -#endif - extern int gchar() { int c; diff --git a/rc.1 b/rc.1 @@ -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-12" +.TH RC 1 "2001-10-31" .SH NAME rc \- shell .SH SYNOPSIS @@ -254,7 +254,8 @@ flag is present, or if the input to .I rc is not from a terminal, then .I rc -will not be in interactive mode. No prompts will be printed, and +will not be in interactive mode. +No prompts will be printed, and .Cr SIGINT will cause .I rc @@ -312,8 +313,8 @@ scripts; the usual caveats about the setuid bit still apply.) .Cr \-s This flag causes .I rc -to read from standard input. Any arguments are -placed in +to read from standard input. +Any arguments are placed in .Cr $* . .TP .Cr \-v @@ -495,12 +496,14 @@ to the same file, use .PP As in .IR sh , -redirections are processed from left to right. Thus this sequence +redirections are processed from left to right. +Thus this sequence .Ds .Cr "command >[2=1] > file" .De .PP -is usually a mistake. It first duplicates standard error to standard +is usually a mistake. +It first duplicates standard error to standard output; then redirects standard output to a file, leaving standard error wherever standard output originally was. .PP @@ -629,7 +632,8 @@ redirection is implemented with some kind of pipe, and since one cannot .IR lseek (2) on a pipe, commands that use .IR lseek (2) -will hang. For example, some versions of +will hang. +For example, some versions of .IR diff (1) use .IR lseek (2) @@ -908,8 +912,9 @@ Note that the null string, .Cr "''" , and the null list, .Cr "()" , -are two very different things. Assigning the null string to a -variable is a valid operation, but it does not remove its definition. +are two very different things. +Assigning the null string to a variable is a valid operation, but it +does not remove its definition. .Ds .Cr "null = '' empty = () echo $#null $#empty" .De @@ -995,7 +1000,8 @@ has no builtin. .PP Any non-empty sequence of characters, except a sequence including only -digits, may be used as a variable name. Any character except +digits, may be used as a variable name. +Any character except .Cr = may be used, but special characters must be quoted. All user-defined variables are exported into the environment. @@ -1009,7 +1015,8 @@ operator: .PP Any variable which has not been assigned a value returns the null list, .Cr "()" , -when referenced. Multiple references are allowed: +when referenced. +Multiple references are allowed: .Ds .Cr "a = foo" .Cr "b = a" @@ -1072,9 +1079,10 @@ Variables may be subscripted with the notation .PP where .I n -is a list of integers (origin 1). The opening parenthesis must -immediately follow the variable name. The list of subscripts need not -be in order or even unique. Thus, +is a list of integers (origin 1). +The opening parenthesis must immediately follow the variable name. +The list of subscripts need not be in order or even unique. +Thus, .Ds .Cr "a=(one two three)" .Cr "echo $a(3 3 3)" @@ -1194,8 +1202,8 @@ as its value. .SH "SPECIAL VARIABLES" Several variables are known to .I rc -and are treated specially. In the following list, -``(read only)'' indicates that an attempt to set the +and are treated specially. +In the following list, ``(read only)'' indicates that an attempt to set the variable will silently have no effect. .TP .Cr * @@ -1249,7 +1257,8 @@ Note also that an assignment to .Cr $cdpath causes an automatic assignment to .Cr $CDPATH , -and vice-versa. Only +and vice-versa. +Only .Cr $CDPATH is exported into the environment. .TP @@ -1361,15 +1370,16 @@ is about to print .Cr "$prompt(1)" . .TP .Cr status " (read only)" -The exit status of the last command. If the command exited with a -numeric value, that number is the status. If the command died with a -signal, the status is the name of that signal; if a core file was -created, the string +The exit status of the last command. +If the command exited with a numeric value, that number is the status. +If the command died with a signal, the status is the name of that signal; +if a core file was created, the string .Rc `` +core '' is appended. The value of .Cr $status for a pipeline is a list, with one entry, as above, for each process -in the pipeline. For example, the command +in the pipeline. +For example, the command .Ds .Cr "ls | wc" .De @@ -1721,11 +1731,13 @@ is printed; for functions, including signal handlers, their definitions are printed; for executable files, path names are printed; and for variables, their values are printed. The flags restrict output to builtins, functions, executable -programs, signal handlers, and variables, respectively. If no +programs, signal handlers, and variables, respectively. +If no .IR name s are specified, .I rc -lists all objects of that type. (This is not permitted for +lists all objects of that type. +(This is not permitted for .Cr \-p .) Without arguments, .Cr whatis @@ -1821,7 +1833,8 @@ prints (with no final newline) .SH "EXIT STATUS" The exit status of .I rc -is normally the same as that of the last command executed. If the +is normally the same as that of the last command executed. +If the last command was a pipeline, .I rc exits @@ -1956,19 +1969,20 @@ On modern systems that support or .Cr /proc/self/fd , .Cr <{foo} -style redirection is implemented that way. However, on older systems -it is implemented with named pipes. Allegedly, it is sometimes -possible to foil +style redirection is implemented that way. +However, on older systems it is implemented with named pipes. +Allegedly, it is sometimes possible to foil .I rc into removing the FIFO it places in .Cr /tmp prematurely, or it is even possible to cause .I rc -to hang. (The current maintainer has never seen this, but then he +to hang. +(The current maintainer has never seen this, but then he doesn't use systems which lack .Cr /dev/fd -any more. If anybody can reproduce this problem, please let the -maintainer know.) +any more. +If anybody can reproduce this problem, please let the maintainer know.) .PP .B echo is built in only for performance reasons, which is a bad idea. @@ -1979,55 +1993,15 @@ Extra parentheses around a .Cr ~ expression or a .Cr ! -expression are a syntax error. Thus, this code is illegal. +expression are a syntax error. +Thus, this code is illegal. .Ds .Cr "while ((~ $1 -*) && (! ~ $1 --)) { ..." .De .TP The redundant inner parentheses must be omitted. .PP -It is usually possible to use parentheses to defeat -free caret insertion; that is, to use -.Cr $(x.y) -as a synonym for -.Cr $'x.y' . -However, the former syntax is not correctly handled in functions -exported to the environment: a function defined using this syntax will -not work properly in descendant -.I rc -processes. -.PP -List definitions in exported functions are "noisier" than they need to be. -.PP -If both -.Cr $PATH -and -.Cr $path -are set, -.I rc -believes the former. Arguably this is a bug: -.I rc -can quite happily deal with path elements that contain -.Cr : , -but such elements will be split at the colon in descendant -.I rc -processes. -.PP -The -.Cr . -command should search -.Cr $path . -.PP -Extra parentheses around a -.Cr ~ -expression or a -.Cr ! -expression are a syntax error. Thus, this -code is illegal. -.Ds -.Cr "while ((~ $1 -*) && (! ~ $1 --)) { ..." -.De -The redundant inner parentheses must be omitted. +Variable subscripting cannot be used in here documents. .PP Bug reports should be mailed to .Cr "<tjg@star.le.ac.uk>" . @@ -2040,7 +2014,8 @@ The Tenth Edition .I rc does not have the .B else -keyword. Instead, +keyword. +Instead, .B if is optionally followed by an @@ -2057,7 +2032,7 @@ This restriction is not present for single-word commands in this .IR rc . .PP For -.Cr . +.Cr . .IR file , the Tenth Edition .IR rc @@ -2072,7 +2047,7 @@ does not, since it is not considered useful. The list flattening operator, .Cr $^foo , is spelt -.Cr "$\"foo" +.Cr "$""foo" in those versions of the Bell Labs .IR rc which have it. diff --git a/rc.h b/rc.h @@ -1,9 +1,9 @@ #define NDEBUG 1 -#include <assert.h> - #include "config.h" #include "proto.h" +#include <assert.h> + /* datatypes */ #define ENV_SEP '\001' diff --git a/trip.rc b/trip.rc @@ -586,3 +586,15 @@ eval z^`{whatis -v x} fn x {echo x.y $(x.y)} ~ ``''{whatis -f x} 'fn x {echo x.y $''x.y''} ' || fail sneaky parens bug + +# large file support + +# this is, by no means, an exhaustive test. since particular file +# systems do, or do not, support large files, we try it both in the +# build directory and /tmp. + +if (./tripping l > big.$pid >[2] /dev/null || + ./tripping l > /tmp/big.$pid >[2] /dev/null) { + echo large file support seems to work +} else echo large file support seems NOT to work - see INSTALL file +rm -f big.$pid /tmp/big.$pid diff --git a/tripping.c b/tripping.c @@ -1,7 +1,12 @@ /* This is an auxiliary test program for rc. */ +#include "config.h" + #include <fcntl.h> #include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <unistd.h> static void out0(void) { putchar('t'); putchar('r'); @@ -14,6 +19,21 @@ static void ctrl_a(void) { puts("a\001ab\002b"); } +static void large(void) { + char c = 'c'; + +#define LARGE (((off_t)1<<33)+1) + + if (lseek(1, LARGE, SEEK_SET) != LARGE) { + perror("lseek"); + exit(1); + } + if (write(1, &c, 1) == -1) { + perror("write"); + exit(1); + } +} + static void makenonblock(void) { int flags; @@ -32,6 +52,9 @@ int main(int argc, char **argv) { case 'a': ctrl_a(); break; + case 'l': + large(); + break; case 'n': makenonblock(); break;