diff options
Diffstat (limited to 'toys')
-rw-r--r-- | toys/other/chroot.c | 9 | ||||
-rw-r--r-- | toys/posix/cmp.c | 3 | ||||
-rw-r--r-- | toys/posix/env.c | 4 | ||||
-rw-r--r-- | toys/posix/nice.c | 8 | ||||
-rw-r--r-- | toys/posix/nohup.c | 6 | ||||
-rw-r--r-- | toys/posix/sort.c | 3 |
6 files changed, 20 insertions, 13 deletions
diff --git a/toys/other/chroot.c b/toys/other/chroot.c index b6ef17d6..d791f34a 100644 --- a/toys/other/chroot.c +++ b/toys/other/chroot.c @@ -7,13 +7,13 @@ * The container guys use pivot_root() to deal with this, which does actually * edit mount tree. (New option? Kernel patch?) -USE_CHROOT(NEWTOY(chroot, "^<1", TOYFLAG_USR|TOYFLAG_SBIN)) +USE_CHROOT(NEWTOY(chroot, "^<1", TOYFLAG_USR|TOYFLAG_SBIN|TOYFLAG_ARGFAIL(125))) config CHROOT bool "chroot" default y help - usage: chroot NEWPATH [commandline...] + usage: chroot NEWROOT [COMMAND [ARG...]] Run command within a new root directory. If no command, run /bin/sh. */ @@ -24,7 +24,10 @@ void chroot_main(void) { char *binsh[] = {"/bin/sh", "-i", 0}; - if (chdir(*toys.optargs) || chroot(".")) perror_exit_raw(*toys.optargs); + if (chdir(*toys.optargs) || chroot(".")) { + toys.exitval = 125; + perror_exit_raw(*toys.optargs); + } if (toys.optargs[1]) xexec(toys.optargs+1); else xexec(binsh); } diff --git a/toys/posix/cmp.c b/toys/posix/cmp.c index 6cd410fc..c573f02e 100644 --- a/toys/posix/cmp.c +++ b/toys/posix/cmp.c @@ -4,7 +4,7 @@ * * See http://opengroup.org/onlinepubs/9699919799/utilities/cmp.html -USE_CMP(NEWTOY(cmp, "<2>2ls(silent)(quiet)[!ls]", TOYFLAG_USR|TOYFLAG_BIN)) +USE_CMP(NEWTOY(cmp, "<2>2ls(silent)(quiet)[!ls]", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_ARGFAIL(2))) config CMP bool "cmp" @@ -81,4 +81,3 @@ void cmp_main(void) loopfiles_rw(toys.optargs, O_CLOEXEC|(WARN_ONLY*!(toys.optflags&FLAG_s)), 0, do_cmp); } - diff --git a/toys/posix/env.c b/toys/posix/env.c index 2de8f690..5c7bb789 100644 --- a/toys/posix/env.c +++ b/toys/posix/env.c @@ -6,13 +6,13 @@ * * Deviations from posix: "-" argument and -0 -USE_ENV(NEWTOY(env, "^0iu*", TOYFLAG_USR|TOYFLAG_BIN)) +USE_ENV(NEWTOY(env, "^0iu*", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_ARGFAIL(125))) config ENV bool "env" default y help - usage: env [-i] [-u NAME] [NAME=VALUE...] [command [option...]] + usage: env [-i] [-u NAME] [NAME=VALUE...] [COMMAND [ARG...]] Set the environment for command invocation, or list environment variables. diff --git a/toys/posix/nice.c b/toys/posix/nice.c index ca5e2224..c26f66d3 100644 --- a/toys/posix/nice.c +++ b/toys/posix/nice.c @@ -10,7 +10,7 @@ config NICE bool "nice" default y help - usage: nice [-n PRIORITY] command [args...] + usage: nice [-n PRIORITY] COMMAND [ARG...] Run a command line at an increased or decreased scheduling priority. @@ -32,7 +32,9 @@ void nice_main(void) if (!toys.optflags) TT.n = 10; errno = 0; - if (nice(TT.n)==-1 && errno) perror_exit("Can't set priority"); - + if (nice(TT.n)==-1 && errno) { + toys.exitval = 125; + perror_exit("Can't set priority"); + } xexec(toys.optargs); } diff --git a/toys/posix/nohup.c b/toys/posix/nohup.c index b302cbe4..e5b526f7 100644 --- a/toys/posix/nohup.c +++ b/toys/posix/nohup.c @@ -4,13 +4,13 @@ * * See http://opengroup.org/onlinepubs/9699919799/utilities/nohup.html -USE_NOHUP(NEWTOY(nohup, "<1^", TOYFLAG_USR|TOYFLAG_BIN)) +USE_NOHUP(NEWTOY(nohup, "<1^", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_ARGFAIL(125))) config NOHUP bool "nohup" default y help - usage: nohup COMMAND [ARGS...] + usage: nohup COMMAND [ARG...] Run a command that survives the end of its terminal. @@ -21,6 +21,7 @@ config NOHUP void nohup_main(void) { + toys.exitval = 125; xsignal(SIGHUP, SIG_IGN); if (isatty(1)) { close(1); @@ -38,5 +39,6 @@ void nohup_main(void) close(0); xopen_stdio("/dev/null", O_RDONLY); } + toys.exitval = 0; xexec(toys.optargs); } diff --git a/toys/posix/sort.c b/toys/posix/sort.c index 9bf81ebc..9d2f2276 100644 --- a/toys/posix/sort.c +++ b/toys/posix/sort.c @@ -7,7 +7,7 @@ * Deviations from POSIX: Lots. * We invented -x -USE_SORT(NEWTOY(sort, USE_SORT_FLOAT("g")"S:T:m" "o:k*t:" "xVbMcszdfirun", TOYFLAG_USR|TOYFLAG_BIN)) +USE_SORT(NEWTOY(sort, USE_SORT_FLOAT("g")"S:T:m" "o:k*t:" "xVbMcszdfirun", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_ARGFAIL(2))) config SORT bool "sort" @@ -345,6 +345,7 @@ void sort_main(void) if (!temp2 || flag>FLAG_x || (flag&(FLAG_u|FLAG_c|FLAG_s|FLAG_z))) { + toys.exitval = 2; error_exit("Unknown key option."); } // b after , means strip _trailing_ space, not leading. |