rc

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

commit c3ebbbf35d712613024488098645f432160f9e26
parent f7a3ce1bd9e66dc46487b3c9f60d11028b9ff35c
Author: tjg <tjg>
Date:   Wed, 13 Oct 1999 16:29:06 +0000

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

Diffstat:
MChangeLog | 2+-
Mbuiltins.c | 10+---------
Mhash.c | 2+-
Mtrip.rc | 2+-
Mvar.c | 8++++++--
5 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -628,4 +628,4 @@ 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. + Feature: replace `-V' with `version' variable. 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_version(char **), b_wait(char **), b_whatis(char **); + b_wait(char **), b_whatis(char **); #if HAVE_SETRLIMIT static void b_limit(char **); @@ -51,7 +51,6 @@ static struct { { b_return, "return" }, { b_shift, "shift" }, { b_umask, "umask" }, - { b_version, "version" }, { b_wait, "wait" }, { b_whatis, "whatis" }, { b_dot, "." }, @@ -249,13 +248,6 @@ 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/hash.c b/hash.c @@ -230,7 +230,7 @@ extern void initenv(char **envp) { static bool var_exportable(char *s) { static char *notforexport[] = { - "apid", "pid", "apids", "*", "ifs" + "apid", "apids", "ifs", "pid", "version", "*" }; int i; for (i = 0; i < arraysize(notforexport); i++) 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 `version +echo tripping $rc $version fn fail { echo >[1=2] trip took a wrong turn: $* diff --git a/var.c b/var.c @@ -57,14 +57,18 @@ extern bool varassign_string(char *extdef) { associated with $status) */ +static List id = { "$Release: @(#)" PACKAGE " " VERSION " " RELDATE " $", 0, 0 }; + extern List *varlookup(char *name) { Variable *look; List *ret, *l; int sub; - if (streq(name, "status")) - return sgetstatus(); if (streq(name, "apids")) return sgetapids(); + if (streq(name, "status")) + return sgetstatus(); + if (streq(name, "version")) + return &id; if (*name != '\0' && (sub = a2u(name)) != -1) { /* handle $1, $2, etc. */ for (l = varlookup("*"); l != NULL && sub != 0; --sub) l = l->n;