diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2021-02-11 17:01:39 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2021-02-11 17:01:39 +0000 |
commit | 6ff749e62652103b3ab84ef145691602ed6e0fea (patch) | |
tree | 330321dc11eda7925cd24cd276ab620f432c94cd /src | |
parent | f3486929d0e96e369a91d68893531b7d8aff1f00 (diff) | |
download | execline-6ff749e62652103b3ab84ef145691602ed6e0fea.tar.xz |
Add helpful error messages on loopwhilex { block } (and ifte too)
Diffstat (limited to 'src')
-rw-r--r-- | src/execline/ifte.c | 8 | ||||
-rw-r--r-- | src/execline/loopwhilex.c | 9 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/execline/ifte.c b/src/execline/ifte.c index d263a4a..1412bf0 100644 --- a/src/execline/ifte.c +++ b/src/execline/ifte.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <errno.h> #include <sys/wait.h> #include <skalibs/sgetopt.h> @@ -41,7 +42,12 @@ int main (int argc, char const **argv, char const *const *envp) if (argc1 + argc2 + 2 >= argc) strerr_dief1x(100, "empty command-if") ; pid = el_spawn0(argv[argc1 + argc2 + 2], argv + argc1 + argc2 + 2, envp) ; - if (!pid) strerr_diefu2sys(111, "spawn ", argv[argc1 + argc2 + 2]) ; + if (!pid) + { + if (errno == ENOENT && argv[argc1 + argc2 + 2][0] == ' ') + strerr_diefu3x(111, "spawn ", argv[argc1 + argc2 + 2], ": name begins with a space, are you trying to spawn a block as your command-if?") ; + else strerr_diefu2sys(111, "spawn ", argv[argc1 + argc2 + 2]) ; + } if (wait_pid(pid, &wstat) == -1) strerr_diefu2sys(111, "wait for ", argv[argc1 + argc2 + 2]) ; if (!flagnormalcrash && WIFSIGNALED(wstat)) diff --git a/src/execline/loopwhilex.c b/src/execline/loopwhilex.c index 93a71e0..5add5e5 100644 --- a/src/execline/loopwhilex.c +++ b/src/execline/loopwhilex.c @@ -1,5 +1,7 @@ /* ISC license. */ +#include <errno.h> + #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/types.h> @@ -58,7 +60,12 @@ int main (int argc, char const *const *argv, char const *const *envp) while (cont) { pid_t pid = el_spawn0(argv[0], argv, envp) ; - if (!pid) strerr_diefu2sys(111, "spawn ", argv[0]) ; + if (!pid) + { + if (errno == ENOENT && argv[0][0] == ' ') + strerr_diefu3x(111, "spawn ", argv[0], ": name begins with a space, are you trying to spawn a block as your loop body?") ; + else strerr_diefu2sys(111, "spawn ", argv[0]) ; + } if (wait_pid(pid, &wstat) < 0) strerr_diefu1sys(111, "wait_pid") ; cont = not != isok(okcodes, nbc, wait_estatus(wstat)) ; } |