diff options
Diffstat (limited to 'src')
33 files changed, 49 insertions, 83 deletions
diff --git a/src/execline/background.c b/src/execline/background.c index 4635146..dc7a01a 100644 --- a/src/execline/background.c +++ b/src/execline/background.c @@ -59,7 +59,6 @@ int main (int argc, char const **argv, char const *const *envp) char fmt[PID_FMT + 2] = "!=" ; size_t i = 2 ; i += pid_fmt(fmt+i, pid) ; fmt[i++] = 0 ; - pathexec_r(argv + argc1 + 1, envp, env_len(envp), fmt, i) ; + xpathexec_r(argv + argc1 + 1, envp, env_len(envp), fmt, i) ; } - strerr_dieexec(111, argv[argc1+1]) ; } diff --git a/src/execline/backtick.c b/src/execline/backtick.c index e3f93c5..a2054ec 100644 --- a/src/execline/backtick.c +++ b/src/execline/backtick.c @@ -96,6 +96,5 @@ int main (int argc, char const **argv, char const *const *envp) if (chomp && (modif.s[modif.len - 2] == '\n')) modif.s[--modif.len - 1] = 0 ; } - pathexec_r(argv + argc1 + 1, envp, env_len(envp), modif.s, modif.len) ; - strerr_dieexec(111, argv[argc1 + 1]) ; + xpathexec_r(argv + argc1 + 1, envp, env_len(envp), modif.s, modif.len) ; } diff --git a/src/execline/cd.c b/src/execline/cd.c index c774ce5..62b877c 100644 --- a/src/execline/cd.c +++ b/src/execline/cd.c @@ -12,6 +12,5 @@ int main (int argc, char const *const *argv, char const *const *envp) if (argc < 3) strerr_dieusage(100, USAGE) ; if (chdir(argv[1]) == -1) strerr_diefu2sys(111, "chdir to ", argv[1]) ; - pathexec_run(argv[2], argv+2, envp) ; - strerr_dieexec(111, argv[2]) ; + xpathexec_run(argv[2], argv+2, envp) ; } diff --git a/src/execline/elgetopt.c b/src/execline/elgetopt.c index b7f0362..6a94fe9 100644 --- a/src/execline/elgetopt.c +++ b/src/execline/elgetopt.c @@ -62,8 +62,7 @@ int main (int argc, char const *const *argv, char const *const *envp) char const *v[envlen] ; if (el_pushenv(&satmp, envp, envlen, list, 1) < 0) goto err ; if (!env_make(v, envlen, satmp.s, satmp.len)) goto err ; - pathexec_r(argv+2, v, envlen, modif.s, modif.len) ; - strerr_dieexec(111, argv[2]) ; + xpathexec_r(argv+2, v, envlen, modif.s, modif.len) ; } err: strerr_diefu1sys(111, "update environment") ; diff --git a/src/execline/emptyenv.c b/src/execline/emptyenv.c index 2a6bc0d..7f6ef59 100644 --- a/src/execline/emptyenv.c +++ b/src/execline/emptyenv.c @@ -1,6 +1,7 @@ /* ISC license. */ #include <string.h> +#include <skalibs/gccattributes.h> #include <skalibs/bytestr.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> @@ -11,6 +12,7 @@ #define USAGE "emptyenv [ -p | -c | -o | -P ] prog..." +static void cleanupenv (char const *const *, char const *const *) gccattr_noreturn ; static void cleanupenv (char const *const *argv, char const *const *envp) { stralloc sa = STRALLOC_ZERO ; @@ -30,8 +32,7 @@ static void cleanupenv (char const *const *argv, char const *const *envp) goto err ; } stralloc_free(&sa) ; - pathexec(argv) ; - strerr_dieexec(111, argv[0]) ; + xpathexec(argv) ; err: strerr_diefu1sys(111, "clean up environment") ; } @@ -69,7 +70,7 @@ int main (int argc, char const *const *argv, char const *const *envp) newenv[0] = *envp ; break ; } - pathexec_run(argv[0], argv, newenv) ; + xpathexec_run(argv[0], argv, newenv) ; } else { @@ -82,9 +83,7 @@ int main (int argc, char const *const *argv, char const *const *envp) char const *v[envlen - n + 1] ; if (!env_make(v, envlen-n, sa.s, sa.len)) strerr_diefu1sys(111, "env_make") ; v[envlen-n] = 0 ; - pathexec_run(argv[0], argv, v) ; + xpathexec_run(argv[0], argv, v) ; } - stralloc_free(&sa) ; } - strerr_dieexec(111, argv[0]) ; } diff --git a/src/execline/exec.c b/src/execline/exec.c index e35d7ba..28c9fd8 100644 --- a/src/execline/exec.c +++ b/src/execline/exec.c @@ -41,8 +41,7 @@ int main (int argc, char const **argv, char const *const *envp) dashed[0] = '-' ; memcpy(dashed+1, argv[0], n+1) ; argv[0] = (char const *)dashed ; - pathexec_run(executable, argv, envp) ; + xpathexec_run(executable, argv, envp) ; } - else pathexec_run(executable, argv, envp) ; - strerr_dieexec(111, executable) ; + else xpathexec_run(executable, argv, envp) ; } diff --git a/src/execline/execlineb.c b/src/execline/execlineb.c index 31cc3ff..64b168d 100644 --- a/src/execline/execlineb.c +++ b/src/execline/execlineb.c @@ -133,7 +133,8 @@ int main (int argc, char const *const *argv, char const *const *envp) { char fmt[UINT_FMT] ; fmt[uint_fmt(fmt, (unsigned int)flagstrict)] = 0 ; - if (!env_addmodif(&modif, "EXECLINE_STRICT", flagstrict ? fmt : 0)) goto errenv ; + if (!env_addmodif(&modif, "EXECLINE_STRICT", flagstrict ? fmt : 0)) + goto errenv ; } if (flagpushenv == 3 || flagpushenv == 4) @@ -158,8 +159,8 @@ int main (int argc, char const *const *argv, char const *const *envp) char fmt[UINT_FMT] ; unsigned int i = 0 ; fmt[uint_fmt(fmt, argc)] = 0 ; - if (!env_addmodif(&modif, "#", fmt)) goto errenv ; - if (!env_addmodif(&modif, "0", dollar0)) goto errenv ; + if (!env_addmodif(&modif, "#", fmt) + || !env_addmodif(&modif, "0", dollar0)) goto errenv ; for (; i < (unsigned int)argc ; i++) { fmt[uint_fmt(fmt, i+1)] = 0 ; @@ -177,18 +178,16 @@ int main (int argc, char const *const *argv, char const *const *envp) static char const *const list[11] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "#" } ; size_t envlen = env_len(envp) ; char const *w[envlen] ; - if (el_pushenv(&satmp, envp, envlen, list, 11) < 0) goto errenv ; - if (!env_make(w, envlen, satmp.s, satmp.len)) goto errenv ; - pathexec_r(v, w, envlen, modif.s, modif.len) ; - stralloc_free(&satmp) ; + if (el_pushenv(&satmp, envp, envlen, list, 11) < 0 + || !env_make(w, envlen, satmp.s, satmp.len)) + goto errenv ; + xpathexec_r(v, w, envlen, modif.s, modif.len) ; } else if (modif.len) - pathexec_r(v, envp, env_len(envp), modif.s, modif.len) ; + xpathexec_r(v, envp, env_len(envp), modif.s, modif.len) ; else - pathexec_run(v[0], v, envp) ; + xpathexec_run(v[0], v, envp) ; } - stralloc_free(&modif) ; - strerr_dieexec(111, sa.s) ; -errenv: + errenv: strerr_diefu1sys(111, "update environment") ; } diff --git a/src/execline/export.c b/src/execline/export.c index 5319c71..fde3adf 100644 --- a/src/execline/export.c +++ b/src/execline/export.c @@ -21,7 +21,6 @@ int main (int argc, char const *const *argv, char const *const *envp) memcpy(fmt, argv[1], len1) ; fmt[len1] = '=' ; memcpy(fmt + len1 + 1, argv[2], len2 + 1) ; - pathexec_r(argv+3, envp, env_len(envp), fmt, len1 + len2 + 2) ; + xpathexec_r(argv+3, envp, env_len(envp), fmt, len1 + len2 + 2) ; } - strerr_dieexec(111, argv[3]) ; } diff --git a/src/execline/fdblock.c b/src/execline/fdblock.c index ec68900..0e912d0 100644 --- a/src/execline/fdblock.c +++ b/src/execline/fdblock.c @@ -29,6 +29,5 @@ int main (int argc, char const *const *argv, char const *const *envp) if ((argc < 2) || !uint0_scan(argv[0], &fd)) strerr_dieusage(100, USAGE) ; if ((block ? ndelay_off(fd) : ndelay_on(fd)) < 0) strerr_diefu1sys(111, block ? "ndelay_off" : "ndelay_on") ; - pathexec_run(argv[1], argv+1, envp) ; - strerr_dieexec(111, argv[1]) ; + xpathexec_run(argv[1], argv+1, envp) ; } diff --git a/src/execline/fdclose.c b/src/execline/fdclose.c index 47780c9..e74c772 100644 --- a/src/execline/fdclose.c +++ b/src/execline/fdclose.c @@ -12,6 +12,5 @@ int main (int argc, char const *const *argv, char const *const *envp) PROG = "fdclose" ; if ((argc < 3) || !uint0_scan(argv[1], &fd)) strerr_dieusage(100, USAGE) ; fd_close(fd) ; - pathexec_run(argv[2], argv+2, envp) ; - strerr_dieexec(111, argv[2]) ; + xpathexec_run(argv[2], argv+2, envp) ; } diff --git a/src/execline/fdmove.c b/src/execline/fdmove.c index 6f97b11..41e2cf1 100644 --- a/src/execline/fdmove.c +++ b/src/execline/fdmove.c @@ -30,6 +30,5 @@ int main (int argc, char const *const *argv, char const *const *envp) strerr_dieusage(100, USAGE) ; if ((flagcopy ? fd_copy(to, from) : fd_move(to, from)) == -1) strerr_diefu4sys(111, "move fd ", argv[1], " to fd ", argv[0]) ; - pathexec_run(argv[2], argv+2, envp) ; - strerr_dieexec(111, argv[2]) ; + xpathexec_run(argv[2], argv+2, envp) ; } diff --git a/src/execline/fdreserve.c b/src/execline/fdreserve.c index 00d5c7d..2c3fc15 100644 --- a/src/execline/fdreserve.c +++ b/src/execline/fdreserve.c @@ -58,7 +58,6 @@ int main (int argc, char const *const *argv, char const *const *envp) j += doit(modif + j, (i<<1)|1, fd[i][1]) ; } } - pathexec_r(argv+2, envp, env_len(envp), modif, j) ; + xpathexec_r(argv+2, envp, env_len(envp), modif, j) ; } - strerr_dieexec(111, argv[2]) ; } diff --git a/src/execline/fdswap.c b/src/execline/fdswap.c index b19494e..57cf4f6 100644 --- a/src/execline/fdswap.c +++ b/src/execline/fdswap.c @@ -13,6 +13,5 @@ int main (int argc, char const *const *argv, char const *const *envp) if ((argc < 4) || !uint0_scan(argv[1], &fd1) || !uint0_scan(argv[2], &fd2)) strerr_dieusage(100, USAGE) ; if (fd_move2(fd1, fd2, fd2, fd1) < 0) strerr_diefu1sys(111, "swap fds") ; - pathexec_run(argv[3], argv+3, envp) ; - strerr_dieexec(111, argv[3]) ; + xpathexec_run(argv[3], argv+3, envp) ; } diff --git a/src/execline/forbacktickx.c b/src/execline/forbacktickx.c index b1b49fa..8b31d92 100644 --- a/src/execline/forbacktickx.c +++ b/src/execline/forbacktickx.c @@ -110,7 +110,6 @@ int main (int argc, char const *const *argv, char const *const *envp) } while (argv[i]) newargv[m++] = argv[i++] ; newargv[m++] = 0 ; - pathexec_run(newargv[0], newargv, envp) ; - strerr_dieexec(111, newargv[0]) ; + xpathexec_run(newargv[0], newargv, envp) ; } } diff --git a/src/execline/getcwd.c b/src/execline/getcwd.c index aeb6691..0548aa8 100644 --- a/src/execline/getcwd.c +++ b/src/execline/getcwd.c @@ -19,6 +19,5 @@ int main (int argc, char const *const *argv, char const *const *envp) strerr_diefu1sys(111, "stralloc_catb") ; if (sagetcwd(&sa) < 0) strerr_diefu1sys(111, "getcwd") ; if (!stralloc_0(&sa)) strerr_diefu1sys(111, "stralloc_catb") ; - pathexec_r(argv + 2, envp, env_len(envp), sa.s, sa.len) ; - strerr_dieexec(111, argv[2]) ; + xpathexec_r(argv + 2, envp, env_len(envp), sa.s, sa.len) ; } diff --git a/src/execline/getpid.c b/src/execline/getpid.c index dd9623a..0272b16 100644 --- a/src/execline/getpid.c +++ b/src/execline/getpid.c @@ -23,7 +23,6 @@ int main (int argc, char const *const *argv, char const *const *envp) memcpy(fmt, argv[1], len) ; fmt[len] = '=' ; i += uint_fmt(fmt+i, getpid()) ; fmt[i++] = 0 ; - pathexec_r(argv+2, envp, env_len(envp), fmt, i) ; + xpathexec_r(argv+2, envp, env_len(envp), fmt, i) ; } - strerr_dieexec(111, argv[2]) ; } diff --git a/src/execline/heredoc.c b/src/execline/heredoc.c index 77e69da..d28d765 100644 --- a/src/execline/heredoc.c +++ b/src/execline/heredoc.c @@ -55,6 +55,5 @@ int main (int argc, char const *const *argv, char const *const *envp) if (fd_move(fdr, fd[0]) == -1) strerr_diefu2sys(111, "read on fd ", argv[0]) ; } - pathexec_run(argv[2], argv+2, envp) ; - strerr_dieexec(111, argv[2]) ; + xpathexec_run(argv[2], argv+2, envp) ; } diff --git a/src/execline/if.c b/src/execline/if.c index 012d9f2..037d4a2 100644 --- a/src/execline/if.c +++ b/src/execline/if.c @@ -47,6 +47,5 @@ int main (int argc, char const **argv, char const *const *envp) strerr_dief2x(128 + WTERMSIG(wstat), "child crashed with signal ", fmt) ; } if (not == !wait_estatus(wstat)) return e ; - pathexec0_run(argv+argc1+1, envp) ; - strerr_dieexec(111, argv[argc1+1]) ; + xpathexec0_run(argv+argc1+1, envp) ; } diff --git a/src/execline/ifelse.c b/src/execline/ifelse.c index c1a2e80..eb10feb 100644 --- a/src/execline/ifelse.c +++ b/src/execline/ifelse.c @@ -49,6 +49,5 @@ int main (int argc, char const **argv, char const *const *envp) strerr_dief2x(128 + WTERMSIG(wstat), "child crashed with signal ", fmt) ; } if (not != !wait_estatus(wstat)) argv[argc2] = 0 ; else argv += argc2+1 ; - pathexec0_run(argv, envp) ; - strerr_dieexec(111, *argv) ; + xpathexec0_run(argv, envp) ; } diff --git a/src/execline/ifte.c b/src/execline/ifte.c index 1bb499e..786621c 100644 --- a/src/execline/ifte.c +++ b/src/execline/ifte.c @@ -53,6 +53,5 @@ int main (int argc, char const **argv, char const *const *envp) argv[argc2] = 0 ; } else argv[argc1] = 0 ; - pathexec0_run(argv, envp) ; - strerr_dieexec(111, *argv) ; + xpathexec0_run(argv, envp) ; } diff --git a/src/execline/ifthenelse.c b/src/execline/ifthenelse.c index b36f549..86dbfe7 100644 --- a/src/execline/ifthenelse.c +++ b/src/execline/ifthenelse.c @@ -64,8 +64,7 @@ int main (int argc, char const **argv, char const *const *envp) unsigned int i = 0 ; for (; remainder[i] ; i++) argv[argc2+i] = remainder[i] ; argv[argc2+i] = 0 ; - pathexec0_run(argv, envp) ; - strerr_dieexec(111, argv[0]) ; + xpathexec0_run(argv, envp) ; } else { diff --git a/src/execline/pipeline.c b/src/execline/pipeline.c index b07d495..3017ea2 100644 --- a/src/execline/pipeline.c +++ b/src/execline/pipeline.c @@ -68,8 +68,7 @@ int main (int argc, char const **argv, char const *const *envp) char fmt[PID_FMT + 2] = "!=" ; size_t i = 2 ; i += pid_fmt(fmt+i, pid) ; fmt[i++] = 0 ; - pathexec_r(argv + argc1 + 1, envp, env_len(envp), fmt, i) ; + xpathexec_r(argv + argc1 + 1, envp, env_len(envp), fmt, i) ; } - strerr_dieexec(111, argv[argc1 + 1]) ; } } diff --git a/src/execline/piperw.c b/src/execline/piperw.c index 8affbde..7f576e5 100644 --- a/src/execline/piperw.c +++ b/src/execline/piperw.c @@ -24,6 +24,5 @@ int main (int argc, char const *const *argv, char const *const *envp) || (fd_move(fdr, p[0]) == -1) || (fd_move(fdw, p[1]) == -1)) strerr_diefu1sys(111, "move fds") ; - pathexec_run(argv[3], argv+3, envp) ; - strerr_dieexec(111, argv[3]) ; + xpathexec_run(argv[3], argv+3, envp) ; } diff --git a/src/execline/redirfd.c b/src/execline/redirfd.c index 8a5c8ef..1539946 100644 --- a/src/execline/redirfd.c +++ b/src/execline/redirfd.c @@ -64,6 +64,5 @@ int main (int argc, char const *const *argv, char const *const *envp) if (((flags & O_NONBLOCK) ? ndelay_off(fd) : ndelay_on(fd)) < 0) strerr_diefu1sys(111, "change blocking mode") ; } - pathexec_run(argv[2], argv+2, envp) ; - strerr_dieexec(111, argv[2]) ; + xpathexec_run(argv[2], argv+2, envp) ; } diff --git a/src/execline/runblock.c b/src/execline/runblock.c index 16fc52a..ab81bb3 100644 --- a/src/execline/runblock.c +++ b/src/execline/runblock.c @@ -129,7 +129,7 @@ int main (int argc, char const *const *argv, char const *const *envp) } if (flagnopop) /* exec now */ - pathexec_run(genalloc_s(char const *, &v)[0], genalloc_s(char const *, &v), envp) ; + xpathexec_run(genalloc_s(char const *, &v)[0], genalloc_s(char const *, &v), envp) ; else /* popenv, then exec */ { char const *list[11] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "#" } ; @@ -142,9 +142,7 @@ int main (int argc, char const *const *argv, char const *const *envp) if (!env_make(w, envlen - popped, satmp.s, satmp.len)) strerr_diefu1sys(111, "env_make") ; w[envlen - popped] = 0 ; - pathexec_run(genalloc_s(char const *, &v)[0], genalloc_s(char const *, &v), w) ; - stralloc_free(&satmp) ; + xpathexec_run(genalloc_s(char const *, &v)[0], genalloc_s(char const *, &v), w) ; } } - strerr_dieexec(111, genalloc_s(char const *, &v)[0]) ; } diff --git a/src/execline/shift.c b/src/execline/shift.c index e936f23..3ca3ede 100644 --- a/src/execline/shift.c +++ b/src/execline/shift.c @@ -116,6 +116,5 @@ int main (int argc, char const *const *argv, char const *const *envp) strerr_diefu1sys(111, "pathexec_env") ; } } - pathexec(argv) ; - strerr_dieexec(111, argv[0]) ; + xpathexec(argv) ; } diff --git a/src/execline/tryexec.c b/src/execline/tryexec.c index 9ba2008..0b1ca87 100644 --- a/src/execline/tryexec.c +++ b/src/execline/tryexec.c @@ -58,6 +58,5 @@ int main (int argc, char const **argv, char const *const *envp) } else pathexec_run(executable, dom, dom_envp) ; - pathexec0_run(sub, envp) ; - strerr_dieexec(111, sub[0]) ; + xpathexec0_run(sub, envp) ; } diff --git a/src/execline/umask.c b/src/execline/umask.c index ab91b37..f74f845 100644 --- a/src/execline/umask.c +++ b/src/execline/umask.c @@ -14,6 +14,5 @@ int main (int argc, char const *const *argv, char const *const *envp) if (argc < 3) strerr_dieusage(100, USAGE) ; if (!uint_oscan(argv[1], &m)) strerr_dieusage(100, USAGE) ; umask(m) ; - pathexec_run(argv[2], argv+2, envp) ; - strerr_dieexec(111, argv[2]) ; + xpathexec_run(argv[2], argv+2, envp) ; } diff --git a/src/execline/unexport.c b/src/execline/unexport.c index e7350e8..0ef46d2 100644 --- a/src/execline/unexport.c +++ b/src/execline/unexport.c @@ -15,6 +15,5 @@ int main (int argc, char const *const *argv, char const *const *envp) len = strlen(argv[1]) ; if (memchr(argv[1], '=', len)) strerr_dief2x(100, "invalid variable name: ", argv[1]) ; - pathexec_r(argv+2, envp, env_len(envp), argv[1], len+1) ; - strerr_dieexec(111, argv[2]) ; + xpathexec_r(argv+2, envp, env_len(envp), argv[1], len+1) ; } diff --git a/src/execline/wait.c b/src/execline/wait.c index 7233304..a7fe22f 100644 --- a/src/execline/wait.c +++ b/src/execline/wait.c @@ -128,6 +128,5 @@ int main (int argc, char const **argv, char const *const *envp) mainloop(&tto, insist, f, tab, &n) ; } - pathexec0_run(argv + argc1 + 1, envp) ; - strerr_dieexec(111, argv[argc1 + 1]) ; + xpathexec0_run(argv + argc1 + 1, envp) ; } diff --git a/src/execline/withstdinas.c b/src/execline/withstdinas.c index 5f62261..da24c8f 100644 --- a/src/execline/withstdinas.c +++ b/src/execline/withstdinas.c @@ -66,6 +66,5 @@ int main (int argc, char const **argv, char const *const *envp) modif.s[--modif.len - 1] = 0 ; } if (!argv[1]) return 0 ; - pathexec_r(argv + 1, envp, env_len(envp), modif.s, modif.len) ; - strerr_dieexec(111, argv[1]) ; + xpathexec_r(argv + 1, envp, env_len(envp), modif.s, modif.len) ; } diff --git a/src/libexecline/el_execsequence.c b/src/libexecline/el_execsequence.c index 42ef104..5adbe49 100644 --- a/src/libexecline/el_execsequence.c +++ b/src/libexecline/el_execsequence.c @@ -18,6 +18,5 @@ void el_execsequence (char const *const *argv1, char const *const *argv2, char c strerr_diefu2sys(111, "wait for ", argv1[0]) ; if (!argv2[0]) _exit(0) ; j += uint_fmt(fmt + j, wait_status(wstat)) ; fmt[j++] = 0 ; - pathexec_r(argv2, envp, env_len(envp), fmt, j) ; - strerr_dieexec(111, argv2[0]) ; + xpathexec_r(argv2, envp, env_len(envp), fmt, j) ; } diff --git a/src/libexecline/el_substandrun_str.c b/src/libexecline/el_substandrun_str.c index 6680957..3f6b8e3 100644 --- a/src/libexecline/el_substandrun_str.c +++ b/src/libexecline/el_substandrun_str.c @@ -20,7 +20,6 @@ void el_substandrun_str (stralloc *src, size_t srcbase, char const *const *envp, char const *v[r + 1] ; if (!env_make(v, r, dst.s, dst.len)) strerr_diefu1sys(111, "env_make") ; v[r] = 0 ; - pathexec_r(v, envp, env_len(envp), info->modifs.s, info->modifs.len) ; + xpathexec_r(v, envp, env_len(envp), info->modifs.s, info->modifs.len) ; } - strerr_dieexec(111, dst.s) ; } |