diff options
| -rw-r--r-- | glom.c | 2 | ||||
| -rw-r--r-- | rc.h | 1 | ||||
| -rw-r--r-- | status.c | 6 | ||||
| -rw-r--r-- | trip.rc | 10 |
4 files changed, 15 insertions, 4 deletions
@@ -266,7 +266,7 @@ static List *backq(Node *ifs, Node *n) { bq = bqinput(glom(ifs), p[0]); close(p[0]); rc_wait4(pid, &sp, TRUE); - statprint(-1, sp); + setstatus(-1, sp); varassign("bqstatus", word(strstatus(sp), NULL), FALSE); sigchk(); return bq; @@ -347,7 +347,6 @@ extern void set(bool); extern void setstatus(pid_t, int); extern List *sgetstatus(void); extern void setpipestatus(int [], int); -extern void statprint(pid_t, int); extern void ssetstatus(char **); extern char *strstatus(int s); @@ -7,6 +7,8 @@ /* status == the wait() value of the last command in the pipeline, or the last command */ +static void statprint(pid_t, int); + static int statuses[512]; static int pipelength = 1; @@ -49,8 +51,8 @@ extern void set(bool code) { extern void setpipestatus(int stats[], int num) { int i; for (i = 0; i < (pipelength = num); i++) { - statprint(-1, stats[i]); statuses[i] = stats[i]; + statprint(-1, stats[i]); } } @@ -64,7 +66,7 @@ extern void setstatus(pid_t pid, int i) { /* print a message if termination was with a signal, and if the child dumped core. exit on error if -e is set */ -extern void statprint(pid_t pid, int i) { +static void statprint(pid_t pid, int i) { if (WIFSIGNALED(i)) { int t = WTERMSIG(i); char *msg = ((t > 0) && (t < NUMOFSIGNALS) ? signals[WTERMSIG(i)].msg : ""); @@ -614,3 +614,13 @@ if (! ~ $X YYY) { A=``($nl){ $rc -c 'mkdir / >[2=1] | tr a-z A-Z' } B=``($nl){ $rc -c '>[2=1] mkdir / | tr a-z A-Z' } ~ $A $B || fail counter intuitive redirection bug, $A '!=' $B + +# test for github issue #40 +$rc -ec 'false | false' +if (~ $status 0) { + fail '"rc -e" exits with zero status when command in pipeline returns non-zero' +} +$rc -ec 'X=`{false}' +if (~ $status 0) { + fail '"rc -e" exits with zero status when backquote command returns non-zero' +} |