FreeBSD Bugzilla – Attachment 198515 Details for
Bug 224270
Get exit status of process that's piped to another: set -o pipefail is missing for /bin/sh
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
possible patch
pipefail.patch (text/plain), 1.50 KB, created by
Alex Richardson
on 2018-10-23 22:39:22 UTC
(
hide
)
Description:
possible patch
Filename:
MIME Type:
Creator:
Alex Richardson
Created:
2018-10-23 22:39:22 UTC
Size:
1.50 KB
patch
obsolete
>diff --git a/bin/sh/Makefile b/bin/sh/Makefile >index abd756bb8e6d..a7cce63a056b 100644 >--- a/bin/sh/Makefile >+++ b/bin/sh/Makefile >@@ -26,7 +26,7 @@ LIBADD= edit > > CFLAGS+=-DSHELL -I. -I${.CURDIR} > # for debug: >-# DEBUG_FLAGS+= -g -DDEBUG=2 -fno-inline >+DEBUG_FLAGS+= -g -DDEBUG=2 -fno-inline > WARNS?= 2 > WFORMAT=0 > >diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c >index 3e6da5fb9ad0..2fdebfb71d3e 100644 >--- a/bin/sh/jobs.c >+++ b/bin/sh/jobs.c >@@ -1076,6 +1076,15 @@ waitforjob(struct job *jp, int *signaled) > setcurjob(jp); > #endif > status = jp->ps[jp->nprocs - 1].status; >+ for (int i = 0; i < jp->nprocs; i++) { >+ TRACE(("waitforjob: ps[%d].status=%d\n", i, jp->ps[i].status)); >+ if (pipefailflag && status == 0 && jp->ps[i].status != 0) { >+ status = jp->ps[i].status; >+ TRACE(("waitforjob: setting pipeline exit status to %d" >+ " since -o pipefail is set\n", status)); >+ } >+ } >+ > if (signaled != NULL) > *signaled = WIFSIGNALED(status); > /* convert to 8 bits */ >diff --git a/bin/sh/options.h b/bin/sh/options.h >index b3819cc2795e..500d4ad5a903 100644 >--- a/bin/sh/options.h >+++ b/bin/sh/options.h >@@ -67,9 +67,10 @@ struct shparam { > #define Pflag optval[17] > #define hflag optval[18] > #define nologflag optval[19] >+#define pipefailflag optval[20] > > #define NSHORTOPTS 19 >-#define NOPTS 20 >+#define NOPTS 21 > > extern char optval[NOPTS]; > extern const char optletter[NSHORTOPTS]; >@@ -97,6 +98,7 @@ static const unsigned char optname[] = > "\010physical" > "\010trackall" > "\005nolog" >+ "\010pipefail" > ; > #endif >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 224270
: 198515 |
198594