aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/cmp.c3
-rw-r--r--toys/posix/env.c4
-rw-r--r--toys/posix/nice.c8
-rw-r--r--toys/posix/nohup.c6
-rw-r--r--toys/posix/sort.c3
5 files changed, 14 insertions, 10 deletions
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.