rc

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

commit f7a3ce1bd9e66dc46487b3c9f60d11028b9ff35c
parent 32514265eae23c9196b09477c63ab26850ecbe6a
Author: tjg <tjg>
Date:   Wed, 13 Oct 1999 16:10:51 +0000

  Feature: replace `-V' with `version' builtin.

Diffstat:
MChangeLog | 2++
Mbuiltins.c | 10+++++++++-
Mmain.c | 7+------
Mtrip.rc | 2+-
4 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -627,3 +627,5 @@ Changes since rc-1.5b2 Portability: use POSIX strerror() where it's available; fake it with sys_errlist[] where not. + + Feature: replace `-V' with `version' builtin. diff --git a/builtins.c b/builtins.c @@ -21,7 +21,7 @@ static void b_break(char **), b_cd(char **), b_eval(char **), b_exit(char **), b_newpgrp(char **), b_return(char **), b_shift(char **), b_umask(char **), - b_wait(char **), b_whatis(char **); + b_version(char **), b_wait(char **), b_whatis(char **); #if HAVE_SETRLIMIT static void b_limit(char **); @@ -51,6 +51,7 @@ static struct { { b_return, "return" }, { b_shift, "shift" }, { b_umask, "umask" }, + { b_version, "version" }, { b_wait, "wait" }, { b_whatis, "whatis" }, { b_dot, "." }, @@ -248,6 +249,13 @@ static void b_shift(char **av) { extern void b_builtin(char **ignore) { } +static void b_version(char **ignore) { + static const char id[] = "$Release: @(#)" PACKAGE " " VERSION " " RELDATE " $"; + + fprint(1, "%s\n", id); + set(TRUE); +} + /* wait for a given process, or all outstanding processes */ static void b_wait(char **av) { diff --git a/main.c b/main.c @@ -11,8 +11,6 @@ static bool dashoh; static void assigndefault(char *,...); static void checkfd(int, enum redirtype); -static const char id[] = "$Release: @(#)" PACKAGE " " VERSION " " RELDATE " $"; - extern int main(int argc, char *argv[], char *envp[]) { char *dashsee[2], *dollarzero, *null[1]; int c; @@ -21,7 +19,7 @@ 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, "c:deilnopsVvx")) != -1) + while ((c = rc_getopt(argc, argv, "c:deilnopsvx")) != -1) switch (c) { case 'c': dashsee[0] = rc_optarg; @@ -50,9 +48,6 @@ extern int main(int argc, char *argv[], char *envp[]) { case 's': dashess = TRUE; break; - case 'V': - fprint(1, "%s\n", id); - exit(0); case 'v': dashvee = TRUE; break; diff --git a/trip.rc b/trip.rc @@ -2,7 +2,7 @@ # Invoke as "path-to-new-rc < trip.rc" rc=$0 -echo tripping $rc +echo tripping $rc `version fn fail { echo >[1=2] trip took a wrong turn: $*