diff --git a/src/execline/backtick.c b/src/execline/backtick.c index 2deb9f3..ae952c8 100644 --- a/src/execline/backtick.c +++ b/src/execline/backtick.c @@ -9,13 +9,13 @@ #include #include -#define USAGE "backtick [ -i | -D default ] [ -n ] var { prog... } command..." +#define USAGE "backtick [ -i | -D default ] [ -z ] [ -n ] var { prog... } command..." #define dieusage() strerr_dieusage(100, USAGE) int main (int argc, char const *const *argv, char const *const *envp) { char const *def = 0 ; - int insist = 0, chomp = 0 ; + int insist = 0, chomp = 0, skip_on_err = 0 ; PROG = "backtick" ; { subgetopt_t l = SUBGETOPT_ZERO ; @@ -29,6 +29,7 @@ int main (int argc, char const *const *argv, char const *const *envp) case 'n' : chomp = 1 ; break ; case 'i' : insist = 1 ; break ; case 'D' : def = l.arg ; break ; + case 'z' : zkip_on_err = 1; break ; default : dieusage() ; } } @@ -57,6 +58,7 @@ int main (int argc, char const *const *argv, char const *const *envp) newargv[m++] = EXECLINE_BINPREFIX "withstdinas" ; if (insist) newargv[m++] = "-i" ; if (chomp) newargv[m++] = "-n" ; + if (skip_on_err) newargv[m++] = "-z" ; if (def) { newargv[m++] = "-D" ; diff --git a/src/execline/withstdinas.c b/src/execline/withstdinas.c index c1e3c36..29a876c 100644 --- a/src/execline/withstdinas.c +++ b/src/execline/withstdinas.c @@ -17,8 +17,8 @@ int main (int argc, char const **argv, char const *const *envp) { subgetopt_t localopt = SUBGETOPT_ZERO ; stralloc modif = STRALLOC_ZERO ; - unsigned int modifstart ; - int insist = 0, chomp = 0, reapit = 0 ; + unsigned int modifstart = 0 ; + int insist = 0, chomp = 0, reapit = 0 , skip_on_err = 0 ; char const *def = 0 ; PROG = "withstdinas" ; for (;;) @@ -31,6 +31,7 @@ int main (int argc, char const **argv, char const *const *envp) case 'n' : chomp = 1 ; break ; case 'D' : def = localopt.arg ; break ; case '!' : reapit = 1 ; break ; + case 'z' : skip_on_err = 1 ; break ; default : dieusage() ; } } @@ -56,7 +57,9 @@ int main (int argc, char const **argv, char const *const *envp) strerr_diefu1sys(111, "waitpid") ; if (wait_estatus(wstat)) { - if (insist) + if (skip_on_err) + modif.len = 2 + else if (insist) if (WIFSIGNALED(wstat)) strerr_dief1x(wait_estatus(wstat), "child process crashed") ; else strerr_dief1x(wait_estatus(wstat), "child process exited non-zero") ; else if (def)