diff options
author | Rob Landley <rob@landley.net> | 2017-05-25 13:27:22 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2017-05-25 13:27:22 -0500 |
commit | 8ab2d8a3fc7be48f327037c477bd58d038ea13b5 (patch) | |
tree | 044934cbede4328d95192813e27d8e5664a89391 | |
parent | e6ac7c1cf4aa18ef01cb29d00b4012f005e2f123 (diff) | |
download | toybox-8ab2d8a3fc7be48f327037c477bd58d038ea13b5.tar.gz |
Add -0 to env.
-rw-r--r-- | toys/posix/env.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/toys/posix/env.c b/toys/posix/env.c index ddb2f598..041c6d95 100644 --- a/toys/posix/env.c +++ b/toys/posix/env.c @@ -3,8 +3,10 @@ * Copyright 2012 Tryn Mirell <tryn@mirell.org> * * http://opengroup.org/onlinepubs/9699919799/utilities/env.html + * + * Deviations from posix: "-" argument and -0 -USE_ENV(NEWTOY(env, "^iu*", TOYFLAG_USR|TOYFLAG_BIN)) +USE_ENV(NEWTOY(env, "^0iu*", TOYFLAG_USR|TOYFLAG_BIN)) config ENV bool "env" @@ -12,10 +14,11 @@ config ENV help usage: env [-i] [-u NAME] [NAME=VALUE...] [command [option...]] - Set the environment for command invocation. + Set the environment for command invocation, or list environment variables. - -i Clear existing environment. + -i Clear existing environment -u NAME Remove NAME from the environment + -0 Use null instead of newline in output */ #define FOR_env @@ -52,5 +55,6 @@ void env_main(void) } else xexec(ev); } - if (environ) for (ev = environ; *ev; ev++) xputs(*ev); + if (environ) for (ev = environ; *ev; ev++) + xprintf("%s%c", *ev, '\n'*!(toys.optflags*FLAG_0)); } |