aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-06-17 13:39:05 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-06-17 13:39:46 +0200
commitc113796884c972244595040466975c74667d4359 (patch)
tree496c315dff060f8dd29208b574cd5d74f789507b
parent91bc01c59b1be5c8a198f72078421e0b6e306a18 (diff)
downloadbusybox-w32-c113796884c972244595040466975c74667d4359.tar.gz
busybox-w32-c113796884c972244595040466975c74667d4359.tar.bz2
busybox-w32-c113796884c972244595040466975c74667d4359.zip
env: implement -0
function old new delta packed_usage 33590 33618 +28 env_main 187 209 +22 .rodata 103242 103250 +8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 58/0) Total: 58 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/env.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/coreutils/env.c b/coreutils/env.c
index 4715bf73a..a0ea4dd27 100644
--- a/coreutils/env.c
+++ b/coreutils/env.c
@@ -39,13 +39,14 @@
39/* http://www.opengroup.org/onlinepubs/007904975/utilities/env.html */ 39/* http://www.opengroup.org/onlinepubs/007904975/utilities/env.html */
40 40
41//usage:#define env_trivial_usage 41//usage:#define env_trivial_usage
42//usage: "[-i] [-u NAME]... [-] [NAME=VALUE]... [PROG ARGS]" 42//usage: "[-i0] [-u NAME]... [-] [NAME=VALUE]... [PROG ARGS]"
43// The "-" can occur only once (unlike, say, -i): it terminates option processing, 43// The "-" can occur only once (unlike, say, -i): it terminates option processing,
44// so if it is followed by another "-" arg (or any option-looking arg), 44// so if it is followed by another "-" arg (or any option-looking arg),
45// that arg will be taken as PROG (or even as NAME=VALUE, example: "-z=QWE"). 45// that arg will be taken as PROG (or even as NAME=VALUE, example: "-z=QWE").
46//usage:#define env_full_usage "\n\n" 46//usage:#define env_full_usage "\n\n"
47//usage: "Print current environment or run PROG after setting up environment\n" 47//usage: "Print current environment or run PROG after setting up environment\n"
48//usage: "\n -, -i Start with empty environment" 48//usage: "\n -, -i Start with empty environment"
49//usage: "\n -0 NUL terminated output"
49//usage: "\n -u NAME Remove variable from environment" 50//usage: "\n -u NAME Remove variable from environment"
50 51
51#include "libbb.h" 52#include "libbb.h"
@@ -56,8 +57,9 @@ int env_main(int argc UNUSED_PARAM, char **argv)
56 unsigned opts; 57 unsigned opts;
57 llist_t *unset_env = NULL; 58 llist_t *unset_env = NULL;
58 59
59 opts = getopt32long(argv, "+iu:*", 60 opts = getopt32long(argv, "+i0u:*",
60 "ignore-environment\0" No_argument "i" 61 "ignore-environment\0" No_argument "i"
62 "null\0" No_argument "0"
61 "unset\0" Required_argument "u" 63 "unset\0" Required_argument "u"
62 , &unset_env 64 , &unset_env
63 ); 65 );
@@ -92,8 +94,9 @@ int env_main(int argc UNUSED_PARAM, char **argv)
92 94
93 if (environ) { /* clearenv() may set environ == NULL! */ 95 if (environ) { /* clearenv() may set environ == NULL! */
94 char **ep; 96 char **ep;
97 opts = (opts & 2) ? 0 : '\n';
95 for (ep = environ; *ep; ep++) { 98 for (ep = environ; *ep; ep++) {
96 puts(*ep); 99 printf("%s%c", *ep, opts);
97 } 100 }
98 } 101 }
99 102