rc

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

commit f983e502ce8fc8d1d0289b8feb269218a70618e6
parent e11c7df86144bed383ac6bbeaecc3017d18b37db
Author: Toby Goodwin <tjg@star.le.ac.uk>
Date:   Wed, 27 Jan 1999 14:01:36 +0000

beta: rc-1.5b5

Diffstat:
MAUTHORS | 9+++++----
MChangeLog | 25+++++++++++++++++++++++++
MMakefile.am | 3+--
MNEWS | 10+++-------
MREADME | 4+---
Mconfigure.ac | 2+-
Mmain.c | 42+++++++++++++++++++++---------------------
Mrc.1 | 137+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
Mtrip.rc | 6++++++
9 files changed, 142 insertions(+), 96 deletions(-)

diff --git a/AUTHORS b/AUTHORS @@ -28,7 +28,8 @@ 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. Arvid Requate, Bengt Kleberg, Brynjulv -Hauksson, Byron Rakitzis, Chris Siebenmann, David Swasey, Gert-Jan Vons, -Ian Lance Taylor, Jeremy Fitzhardinge, Marc Moorcroft, Mark K Gardner, -Raymond Venneker, Rich $alz, Rob Savoye, Scott Schwartz, Stefan Dalibor, -Tom Culliton, Tom Tromey, Vincent Broman. +Hauksson, Byron Rakitzis, Chris Siebenmann, David Swasey, Gerry +Tomlinson, Gert-Jan Vons, Ian Lance Taylor, Jeremy Fitzhardinge, Marc +Moorcroft, Mark K Gardner, Raymond Venneker, Rich $alz, Rob Savoye, +Scott Schwartz, Stefan Dalibor, Tom Culliton, Tom Tromey, Vincent +Broman. diff --git a/ChangeLog b/ChangeLog @@ -529,3 +529,28 @@ Changes since rc-1.5b2 Documentation: the Bell Labs rc now has the list flattening operator, but spelt $"foo. + +1999-01-11 + + Release: rc-1.5b4. + +1999-01-19 + + Documentation: document the `-s' option. Also, arrange the option + documentation in alphabetical order. + + Tidiness: just install `history' to `$(bindir)/-'; don't create an + extra link (which `make clean' failed to remove). + +1999-01-22 + + Bug: `-s' should not imply `-i'. + + Testing: add regression test for `-s' behaviour. + +1999-01-27 + + Documentation: default path was out of date; minor consistency + improvements. + + Release: rc-1.5b5. diff --git a/Makefile.am b/Makefile.am @@ -61,8 +61,7 @@ trip: rc tripping install-exec-hook: if AMC_HISTORY - $(LN) history - ;\ - $(INSTALL_PROGRAM) - $(bindir) ;\ + $(INSTALL_PROGRAM) history $(bindir)/- ;\ rm -f $(bindir)/--; $(LN) $(bindir)/- $(bindir)/-- ;\ rm -f $(bindir)/-p; $(LN) $(bindir)/- $(bindir)/-p ;\ rm -f $(bindir)/--p; $(LN) $(bindir)/- $(bindir)/--p diff --git a/NEWS b/NEWS @@ -3,7 +3,7 @@ autoconfiguration code, some of them critical. One problem (which I introduced) was found in minutes with ElectricFence: I had spent several hours failing to find it with other tools. -Two bugs in rc itself, one of them trivial, were fixed. +Three bugs in rc itself, one of them trivial, were fixed. rc now uses GNU automake. Although I feel that automake is sticking plaster to mend a broken leg, it has made my job as maintainer easier. @@ -30,7 +30,7 @@ information only. The supplied y.tab.[ch] were built with Berkeley `yacc', and lightly edited to remove a few gcc warnings. This idea was suggested by Gert-Jan Vons. -Binaries of rc-1.5b4 are typically a few kilobytes smaller than 1.5b2. +Binaries of rc-1.5b5 are typically a few kilobytes smaller than 1.5b2. I believe this is due to improved autoconfiguration: we are now much more careful only to include code that will be used. @@ -42,9 +42,5 @@ non-blocking mode. See ChangeLog for more details. -What happened to rc-1.5b3? There were a couple of releases to people -who'd found bugs in rc-1.5b2 that were called b3. To avoid any -possibility of confusion, I have named this beta release rc-1.5b4. - Tim Goodwin -1999-01-11 +1999-01-27 diff --git a/README b/README @@ -1,5 +1,4 @@ -This is a snapshot release of rc-1.5. The file RELDATE identifies the -date of the snapshot. +This is a beta release, rc-1.5b5. See COPYING for copying information. All files are @@ -37,4 +36,3 @@ WWW More information on releases of rc can be found at this web page. http://www.star.le.ac.uk/~tjg/rc/ - 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.5s`echo $RELDATE |sed 's/-//g'`) dnl ...and this one for releases -AM_INIT_AUTOMAKE(rc, 1.5b4) +AM_INIT_AUTOMAKE(rc, 1.5b5) AM_CONFIG_HEADER(config.h) diff --git a/main.c b/main.c @@ -21,10 +21,13 @@ extern int main(int argc, char *argv[], char *envp[]) { dollarzero = argv[0]; rc_pid = getpid(); dashell = (*argv[0] == '-'); /* Unix tradition */ - while ((c = rc_getopt(argc, argv, "Vnolpeivdxsc:")) != -1) + while ((c = rc_getopt(argc, argv, "c:deilnopsVvx")) != -1) switch (c) { - case 'l': - dashell = TRUE; + case 'c': + dashsee[0] = rc_optarg; + goto quitopts; + case 'd': + dashdee = TRUE; break; case 'e': dashee = TRUE; @@ -32,40 +35,37 @@ extern int main(int argc, char *argv[], char *envp[]) { case 'i': dasheye = interactive = TRUE; break; - case 'v': - dashvee = TRUE; - break; - case 'x': - dashex = TRUE; - break; - case 'd': - dashdee = TRUE; - break; - case 's': - dashess = dasheye = interactive = TRUE; + case 'l': + dashell = TRUE; break; - case 'c': - dashsee[0] = rc_optarg; - goto quitopts; case 'n': dashen = TRUE; break; + case 'o': + dashoh = TRUE; + break; case 'p': dashpee = TRUE; break; - case 'o': - dashoh = TRUE; + case 's': + dashess = TRUE; break; case 'V': fprint(1, "%s\n", id); exit(0); + case 'v': + dashvee = TRUE; + break; + case 'x': + dashex = TRUE; + break; case '?': exit(1); } quitopts: argv += rc_optind; - /* use isatty() iff -i is not set, and iff the input is not from a script or -c or -s flags */ - if (!dasheye && !dashess && dashsee[0] == NULL && *argv == NULL) + /* use isatty() iff -i is not set, and iff the input is not from a script or -c flags */ + if (!dasheye && dashsee[0] == NULL && (dashess || *argv == NULL)) interactive = isatty(0); if (!dashoh) { checkfd(0, rFrom); diff --git a/rc.1 b/rc.1 @@ -166,7 +166,7 @@ rc \- shell .SH SYNOPSIS .B rc -.RB [ \-eixvldnpoV ] +.RB [ \-deilnopsVvx ] .RB [ \-c .IR command ] .RI [ arguments ] @@ -183,10 +183,44 @@ Its use is intended to be interactive, but the language lends itself well to scripts. .SH OPTIONS .TP +.Cr \-c +If +.Cr \-c +is present, commands are executed from the immediately following +argument. +Any further arguments to +.I rc +are placed in +.Cr $* . +Thus: +.Ds +.Cr "rc -c 'echo $*' 1 2 3" +.De +.TP +\& +prints out +.Ds +.Cr "1 2 3" +.De +.TP +.Cr \-d +This flag causes +.I rc +not to ignore +.Cr SIGQUIT +or +.Cr SIGTERM . +Thus +.I rc +can be made to dump core if sent +.Cr SIGQUIT . +This flag is only useful for debugging +.IR rc . +.TP .Cr \-e If the .Cr \-e -option is present, then +flag is present, then .I rc will exit if the exit status of a command is false (nonzero). .I rc @@ -197,7 +231,7 @@ command. .Cr \-i If the .Cr \-i -option is present or if the input to +flag is present or if the input to .I rc is from a terminal (as determined by .IR isatty (3)) @@ -216,23 +250,10 @@ will ignore the signals and .Cr SIGQUIT . .TP -.Cr \-x -This option will make -.I rc -print every command on standard error before it is executed. -It can be useful for debugging -.I rc -scripts. -.TP -.Cr \-v -This option will echo input to -.I rc -on standard error as it is read. -.TP .Cr \-l If the .Cr \-l -option is present, or if +flag is present, or if .IR rc 's .Cr argv[0][0] is a dash @@ -244,20 +265,6 @@ That is, it will try to run commands present in .Cr $home/.rcrc , if this file exists, before reading any other input. .TP -.Cr \-d -This flag causes -.I rc -not to ignore -.Cr SIGQUIT -or -.Cr SIGTERM . -Thus -.I rc -can be made to dump core if sent -.Cr SIGQUIT . -This option is only useful for debugging -.IR rc . -.TP .Cr \-n This flag causes .I rc @@ -265,11 +272,17 @@ to read its input and parse it, but not to execute any commands. This is useful for syntax checking on scripts. If used in combination with the .Cr \-x -option, +flag, .I rc will print each command as it is parsed in a form similar to the one used for exporting functions into the environment. .TP +.Cr \-o +This flag prevents the usual practice of trying to open +.Cr /dev/null +on file descriptors 0, 1, and 2, if any of those descriptors +are inherited closed. +.TP .Cr \-p This flag prevents .I rc @@ -280,31 +293,36 @@ to run in a protected mode, whereby it becomes more difficult for an .I rc script to be subverted by placing false commands in the environment. -(Note that this presence of this option does NOT mean that it is safe to +(Note that this presence of this flag does NOT mean that it is safe to run setuid .I rc scripts; the usual caveats about the setuid bit still apply.) .TP -.Cr \-o -This flag prevents the usual practice of trying to open -.Cr /dev/null -on file descriptors 0, 1, and 2, if any of those descriptors -are inherited closed. -.TP -.Cr \-c -If -.Cr \-c -is present, commands are executed from the immediately following -argument. -Any further arguments to +.Cr \- s +This flag causes .I rc -are placed in +to read from standard input. Any arguments are +placed in .Cr $* . .TP .Cr \-V This flag causes .I rc to print a version string to stdout, and exit immediately. +.TP +.Cr \-v +This flag causes +.I rc +to echo its input +to standard error as it is read. +.TP +.Cr \-x +This flag causes +.I rc +to print every command on standard error before it is executed. +It can be useful for debugging +.I rc +scripts. .PP .SH COMMANDS A simple command is a sequence of words, separated by white space @@ -1238,7 +1256,7 @@ is not set at startup time, .Cr $path assumes a default value suitable for your system. This is typically -.Cr "(/usr/ucb /usr/bin /bin .)" +.Cr "(/usr/local/bin /usr/bin /usr/ucb /bin .)" .TP .Cr pid The process ID of the currently running @@ -1641,7 +1659,7 @@ For builtins, 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 options restrict output to builtins, functions, executable +The flags restrict output to builtins, functions, executable programs, signal handlers, and variables, respectively. If no .IR name s are specified, @@ -1683,7 +1701,7 @@ uses .IR getopt (3) to parse its arguments, you can use the special argument .Cr "\-\|\-" -to terminate its options. +to terminate its flags. This allows you to use names beginning with a dash, such as the .IR history (1) @@ -1846,15 +1864,18 @@ Here is a list of features which distinguish this incarnation of .I rc from the one described in the Bell Labs manual pages: .PP -The treatment of -.Cr if - else -is different in the v10 -.IR rc : -that version uses an -.Cr "if not" -clause which gets executed +The v10 +.I rc +does not have the +.B else +keyword. Instead, +.B if +is optionally followed by +an +.B "if not" +clause which is executed if the preceding -.Cr if +.B if test does not succeed. .PP Backquotes are slightly different in v10 @@ -1875,7 +1896,7 @@ The following are all new with this version of .IR rc : The .Cr \-n -option, +flag, here strings (they facilitate exporting of functions with here documents into the environment), the diff --git a/trip.rc b/trip.rc @@ -559,3 +559,9 @@ expect date x=`{ { sleep 1; echo echo foo } | { ./tripping n; $rc >[2=1] } } if (!~ foo $x) fail input file descriptor nonblocking + +# `rc -s' reads from stdin, but should not imply `-i' +expect foo bar qux +$rc -s foo bar qux <<'eof' +echo $* +eof