]> git.mdlowis.com Git - proto/rc.git/commitdiff
Removed all command line flags in the interest of stripping things down to barebones...
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 16 Mar 2017 19:59:47 +0000 (15:59 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 16 Mar 2017 19:59:47 +0000 (15:59 -0400)
13 files changed:
Makefile
builtins.c
exec.c
fn.c
glom.c
hash.c
input.c
main.c
print.c
rc.h
sigmsgs.c
status.c
walk.c

index f584a26cf652e72702ba599353e3d9d64422a826..3519ae80df17f4a57b9c07986fd6ae1c1bbb9bf6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,12 +5,6 @@ RCOBJS = builtins.o except.o exec.o fn.o footobar.o glob.o glom.o hash.o heredoc
 
 all: rc
 
-# Generate mkstatval
-mkstatval: mkstatval.o
-statval.h: mkstatval
-       ./mkstatval > statval.h
-status.o: statval.h
-
 lex.o: y.tab.h
 y.tab.c y.tab.h: parse.y
        $(YACC) -d $<
index 130dc096cbd7de340b9f24318b2944cc663a7ae5..8d338a12274476202ddca3f0d58b135ea120dbac 100644 (file)
@@ -11,7 +11,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_limit(char **), b_echo(char **);
+       b_wait(char **), b_limit(char **), b_echo(char **);
 
 static struct {
        builtin_t *p;
@@ -252,14 +252,6 @@ static void b_wait(char **av) {
 #define not(b) ((b)^true)
 #define show(b)        (not(eff|vee|pee|bee|ess)|(b))
 
-static bool issig(char *s) {
-       int i;
-       for (i = 0; i < NSIG; i++)
-               if (streq(s, signals[i].name))
-                       return true;
-       return false;
-}
-
 /* push a string to be eval'ed onto the input stack. evaluate it */
 
 static void b_eval(char **av) {
@@ -289,10 +281,6 @@ extern void b_dot(char **av) {
                av++;
                i = true;
        }
-       if (dasheye) { /* rc -i file has to do the right thing. reset the dasheye state to false, though. */
-               dasheye = false;
-               i = true;
-       }
        if (*av == NULL)
                return;
        fd = rc_open(*av, rFrom);
diff --git a/exec.c b/exec.c
index af8043e54e4b45e29931522cbac4b591c050ff51..dd2567135b8ee3fefc66dbefbb53161452140502 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -14,7 +14,7 @@ extern void exec(List *s, bool parent) {
        builtin_t *b;
        char *path = NULL;
        bool didfork, returning, saw_exec, saw_builtin;
-       av = list2array(s, dashex);
+       av = list2array(s, false);
        saw_builtin = saw_exec = false;
        do {
                if (*av == NULL || isabsolute(*av))
diff --git a/fn.c b/fn.c
index 24bd9254db43cd38c959d8be82401da5db9bf1ed..0d739322d3504c6a6bfb1235fb3e8d72cf1a56e4 100644 (file)
--- a/fn.c
+++ b/fn.c
@@ -29,15 +29,15 @@ extern void inithandler() {
                def_sigint = sigint;
                fnrm("sigint"); /* installs SIGINT catcher if not inherited ignored */
        }
-       if (!dashdee) {
-               if (interactive || sighandlers[SIGQUIT] != SIG_IGN) {
-                       def_sigquit = dud_handler;
-                       fnrm("sigquit"); /* "ignores" SIGQUIT unless inherited ignored */
-               }
-               if (interactive) {
-                       def_sigterm = dud_handler;
-                       fnrm("sigterm"); /* ditto for SIGTERM */
-               }
+
+       if (interactive || sighandlers[SIGQUIT] != SIG_IGN) {
+               def_sigquit = dud_handler;
+               fnrm("sigquit"); /* "ignores" SIGQUIT unless inherited ignored */
+       }
+
+       if (interactive) {
+               def_sigterm = dud_handler;
+               fnrm("sigterm"); /* ditto for SIGTERM */
        }
 }
 
diff --git a/glom.c b/glom.c
index a787f25374bdc70986edd66f61276add7ee0afc9..6f3a65c0fdd5ce5f1ad3d962022164b1415c6dba 100644 (file)
--- a/glom.c
+++ b/glom.c
@@ -152,13 +152,9 @@ extern void assign(List *s1, List *s2, bool stack) {
        if (*s1->w == '*' && s1->w[1] == '\0')
                val = append(varlookup("0"), s2); /* preserve $0 when * is assigned explicitly */
        if (s2 != NULL || stack) {
-               if (dashex)
-                       prettyprint_var(2, s1->w, val);
                varassign(s1->w, val, stack);
                alias(s1->w, varlookup(s1->w), stack);
        } else {
-               if (dashex)
-                       prettyprint_var(2, s1->w, NULL);
                varrm(s1->w, stack);
        }
 }
diff --git a/hash.c b/hash.c
index aa66f3909e7021ce6a9f5ee46a83ee4ca8af17df..2f3b3b9debc98651799d7a01b8d0402bfed6d271 100644 (file)
--- a/hash.c
+++ b/hash.c
@@ -219,8 +219,7 @@ extern void initenv(char **envp) {
        env = ealloc((envsize = 2 * n) * sizeof (char *));
        for (; *envp != NULL; envp++)
                if (strncmp(*envp, "fn_", conststrlen("fn_")) == 0) {
-                       if (!dashpee)
-                               fnassign_string(*envp);
+                       fnassign_string(*envp);
                } else {
                        if (!varassign_string(*envp)) /* add to bozo env */
                                env[bozosize++] = *envp;
diff --git a/input.c b/input.c
index b78075e9af3b9acee5ea91e3b29001adec5d0354..ab39582a71df0917b87883b66e2bf17950324748 100644 (file)
--- a/input.c
+++ b/input.c
@@ -118,8 +118,6 @@ static int fdgchar() {
                if (chars_in == 0)
                        return lastchar = EOF;
                chars_out = 0;
-               if (dashvee)
-                       writeall(2, inbuf, chars_in);
                history();
        }
 
@@ -219,8 +217,6 @@ extern Node *doit(bool clobberexecit) {
        Estack e1;
        Edata jerror;
 
-       if (dashen)
-               clobberexecit = false;
        execit = clobberexecit;
        sigsetjmp(j.j, 1);
        jerror.jb = &j;
@@ -235,7 +231,7 @@ extern Node *doit(bool clobberexecit) {
 
                if (interactive) {
                        List *s;
-                       if (!dashen && fnlookup("prompt") != NULL) {
+                       if (fnlookup("prompt") != NULL) {
                                static bool died = false;
                                static char *arglist[] = { "prompt", NULL };
 
@@ -262,12 +258,8 @@ extern Node *doit(bool clobberexecit) {
                if (yyparse() == 1 && execit)
                        rc_raise(eError);
                eof = (lastchar == EOF); /* "lastchar" can be clobbered during a walk() */
-               if (parsetree != NULL) {
-                       if (execit)
+               if (parsetree != NULL && execit)
                                walk(parsetree, true);
-                       else if (dashex && dashen)
-                               fprint(2, "%T\n", parsetree);
-               }
                unexcept(); /* eArena */
        }
        popinput();
diff --git a/main.c b/main.c
index 7ece9618b2f64c7cd649702499be7202fe88b64d..c188efa60624be3dc6877bdcee3033c31c5b97c6 100644 (file)
--- a/main.c
+++ b/main.c
@@ -3,12 +3,9 @@
 #include "rc.h"
 
 char* ARGV0;
-bool dashdee, dashee, dashvee, dashex, dasheye,
-       dashen, dashpee, interactive;
+bool interactive;
 pid_t rc_pid;
 
-static bool dashEYE, dashell, dashoh, dashess;
-
 static void assigndefault(char *,...);
 static void checkfd(int, enum redirtype);
 
@@ -17,51 +14,22 @@ void usage(void) {
 }
 
 extern int main(int argc, char *argv[], char *envp[]) {
-       char *dashsee[2], *dollarzero, *null[1];
+       char *dollarzero, *null[1];
        initprint();
-       dashsee[0] = dashsee[1] = NULL;
-       dollarzero = argv[0];
+       ARGV0 = dollarzero = argv[0];
        rc_pid = getpid();
-       dashell = (*argv[0] == '-'); /* login shell, per unix tradition */
-       
-       OPTBEGIN {
-               case 'd': dashdee = true; break;
-               case 'e': dashee  = true; break;
-               case 'l': dashell = true; break;
-               case 'n': dashen  = true; break;
-               case 'o': dashoh  = true; break;
-               case 'p': dashpee = true; break;
-               case 's': dashess = true; break;
-               case 'v': dashvee = true; break;
-               case 'x': dashex  = true; break;
-               case 'i': 
-                       dasheye = true;
-                       interactive = true; 
-                       break;
-               case 'I':
-                       dashEYE = true;
-                       interactive = false;
-                       break;
-               case 'c':
-                       dashsee[0] = EOPTARG(usage());
-                       break;
-       } OPTEND;
 
        /* use isatty() iff neither -i nor -I is set, and iff the input is not from a script or -c flags */
-       if (!dasheye && !dashEYE && dashsee[0] == NULL && (dashess || *argv == NULL))
-               interactive = isatty(0);
-       if (!dashoh) {
-               checkfd(0, rFrom);
-               checkfd(1, rCreate);
-               checkfd(2, rCreate);
-       }
+       interactive = isatty(0);
+       checkfd(0, rFrom);
+       checkfd(1, rCreate);
+       checkfd(2, rCreate);
+       
        initsignal();
        inithash();
        initparse();
        assigndefault("ifs", " ", "\t", "\n", (void *)0);
-#ifdef DEFAULTPATH
        assigndefault("path", DEFAULTPATH, (void *)0);
-#endif
        assigndefault("pid", nprint("%d", rc_pid), (void *)0);
        assigndefault("prompt", "; ", "", (void *)0);
        assigndefault("version", VERSION, "$Release: @(#)" PACKAGE " " VERSION " " RELDATE " $", (void *)0);
@@ -71,41 +39,7 @@ extern int main(int argc, char *argv[], char *envp[]) {
        starassign(dollarzero, null, false); /* assign $0 to $* */
        inithandler();
 
-       if (dashell) {
-               char *rcrc;
-               int fd;
-
-               rcrc = concat(varlookup("home"), word("/.rcrc", NULL))->w;
-               fd = rc_open(rcrc, rFrom);
-               if (fd == -1) {
-                       if (errno != ENOENT)
-                               uerror(rcrc);
-               } else {
-                       bool push_interactive;
-
-                       pushfd(fd);
-                       push_interactive = interactive;
-                       interactive = false;
-                       doit(true);
-                       interactive = push_interactive;
-                       close(fd);
-               }
-       }
-
-       if (dashsee[0] != NULL || dashess) {    /* input from  -c or -s? */
-               if (*argv != NULL)
-                       starassign(dollarzero, argv, false);
-               if (dashess)
-                       pushfd(0);
-               else
-                       pushstring(dashsee, true);
-       } else if (*argv != NULL) {     /* else from a file? */
-               b_dot(--argv);
-               rc_exit(getstatus());
-       } else {                        /* else stdin */
-               pushfd(0);
-       }
-       dasheye = false;
+       pushfd(0); // Read stdin
        doit(true);
        rc_exit(getstatus());
        return 0; /* Never really reached. */
diff --git a/print.c b/print.c
index f5e31bda48053520f25363c6f3f72ffd2ed23456..ff8e9e5f616bcdd0b7811265410b33836456f1a6 100644 (file)
--- a/print.c
+++ b/print.c
@@ -20,7 +20,6 @@ static bool name(Format *format, int ignore) { \
 
 Flag(uconv,        FMT_unsigned)
 Flag(rc_lconv, FMT_long)
-Flag(qconv,        FMT_quad)
 Flag(altconv,  FMT_altform)
 Flag(leftconv, FMT_leftside)
 Flag(dotconv,  FMT_f2set)
@@ -372,4 +371,4 @@ extern void writeall(int fd, char *buf, size_t remain) {
                if ((i = write(fd, buf, remain)) <= 0)
                        break; /* abort silently on errors in write() */
        sigchk();
-}
\ No newline at end of file
+}
diff --git a/rc.h b/rc.h
index 9ec371767608d7e198aff56d6c4113def6c40760..d21cd8d7e6f984a183c8ba24936fa6280d6a18d0 100644 (file)
--- a/rc.h
+++ b/rc.h
@@ -9,6 +9,7 @@
 #define RC_JOB        1
 #define RELDATE       "2017-03-13"
 #define VERSION       "1.7.4"
+#define RC            "rc: "
 
 /* C standard includes */
 #include <stdlib.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 
-typedef long align_t;
 
-/* If we have POSIX sigjmp_buf and friends, use them.  If we don't, just
-use a jmp_buf.  This probably fails on a traditional SysV machine, where
-jmp_bufs don't preserve signal masks.  I'm not worrying about this till
-someone reports it as a bug :-). */
+/* 
+    These were generated by mkstatval but generated the same on OSX
+    and linux. Hardcoded here but should revisit what they actually 
+    mean and if there is a more standard compliant approach 
+*/
+#define STATUS0 0
+#define STATUS1 256
+
+typedef long align_t;
 
 /* Certain braindamaged environments don't define jmp_buf as an array,
 so wrap it in a structure.  Potentially, we could use configure to do
@@ -76,8 +81,6 @@ typedef struct {
 
 extern Sigmsgs signals[NSIG];
 
-#define RC "rc: "
-
 /* datatypes */
 
 #define ENV_SEP '\001'
@@ -230,7 +233,7 @@ enum {
 
 /* main.c */
 extern Rq *redirq;
-extern bool dashdee, dashee, dashvee, dashex, dasheye, dashen, dashpee, interactive;
+extern bool dashee, dashvee, dashex, dasheye, dashpee, interactive;
 extern pid_t rc_pid;
 extern int lineno;
 
@@ -371,10 +374,6 @@ extern Node *parsetree;
 extern int yyparse(void);
 extern void initparse(void);
 
-/* readline */
-extern volatile sig_atomic_t rl_active;
-extern struct Jbwrap rl_buf;
-
 /* redir.c */
 extern void doredirs(void);
 
index c769a4e16ae390b0b84dee8677b3b7d941abd0e6..02082af7e38606ca33406717623faca7ee0666ed 100644 (file)
--- a/sigmsgs.c
+++ b/sigmsgs.c
@@ -49,9 +49,6 @@ Sigmsgs signals[NSIG] = {
 #ifdef SIGSTKFLT
     [SIGSTKFLT] = { "sigstkflt", "stack fault" },
 #endif
-#ifdef SIGCLD
-    [SIGCLD]    = { "sigcld",    "child stop or exit" },
-#endif
 #ifdef SIGCHLD
     [SIGCHLD]   = { "sigchld",   "child status has changed" },
 #endif
@@ -91,9 +88,6 @@ Sigmsgs signals[NSIG] = {
 #ifdef SIGPOLL
     [SIGPOLL]   = { "sigpoll",   "pollable event occurred" },
 #endif
-#ifdef SIGIO
-    [SIGIO]     = { "sigio",     "i/o now possible" },
-#endif
 #ifdef SIGPWR
     [SIGPWR]    = { "sigpwr",    "power failure restart" },
 #endif
index cc5936315d107b8c2596d030ba79841b1f5cec01..ae4fef5c43dec85e01963da2f29daefbfdf63ff7 100644 (file)
--- a/status.c
+++ b/status.c
@@ -1,7 +1,6 @@
 /* status.c: functions for printing fancy status messages in rc */
 
 #include "rc.h"
-#include "statval.h"
 
 /* not defined by posix but useful nonetheless */
 #define myWIFDUMPED(s) (((s) & 0x80) != 0)
@@ -79,8 +78,6 @@ extern void statprint(pid_t pid, int i) {
                } else if (*msg != '\0')
                        fprint(2, "%s\n", msg);
        }
-       if (i != 0 && dashee && !cond)
-               rc_exit(getstatus());
 }
 
 /* prepare a list to be passed back. Used whenever $status is dereferenced */
diff --git a/walk.c b/walk.c
index b6b814928cc35c74b0f345527d25a8287b4e3b66..1787b1ac9d736a6ced8746023253879baab2abb8 100644 (file)
--- a/walk.c
+++ b/walk.c
@@ -164,8 +164,6 @@ top:        sigchk();
                if (l == NULL)
                        rc_error("null function name");
                while (l != NULL) {
-                       if (dashex)
-                               prettyprint_fn(2, l->w, n->u[1].p);
                        fnassign(l->w, n->u[1].p);
                        l = l->n;
                }
@@ -175,8 +173,6 @@ top:        sigchk();
        case nRmfn: {
                List *l = glom(n->u[0].p);
                while (l != NULL) {
-                       if (dashex)
-                               fprint(2, "fn %S\n", l->w);
                        fnrm(l->w);
                        l = l->n;
                }
@@ -188,8 +184,6 @@ top:        sigchk();
                break; /* Null command */
        case nMatch: {
                List *a = glob(glom(n->u[0].p)), *b = glom(n->u[1].p);
-               if (dashex)
-                       fprint(2, (a != NULL && a->n != NULL) ? "~ (%L) %L\n" : "~ %L %L\n", a, " ", b, " ");
                set(lmatch(a, b));
                break;
        }