diff options
Diffstat (limited to 'coreutils/env.c')
-rw-r--r-- | coreutils/env.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/coreutils/env.c b/coreutils/env.c index c37c0c2df..a0ea4dd27 100644 --- a/coreutils/env.c +++ b/coreutils/env.c | |||
@@ -39,12 +39,15 @@ | |||
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: "[-iu] [-] [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, | ||
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"). | ||
43 | //usage:#define env_full_usage "\n\n" | 46 | //usage:#define env_full_usage "\n\n" |
44 | //usage: "Print the current environment or run PROG after setting up\n" | 47 | //usage: "Print current environment or run PROG after setting up environment\n" |
45 | //usage: "the specified environment\n" | 48 | //usage: "\n -, -i Start with empty environment" |
46 | //usage: "\n -, -i Start with an empty environment" | 49 | //usage: "\n -0 NUL terminated output" |
47 | //usage: "\n -u Remove variable from the environment" | 50 | //usage: "\n -u NAME Remove variable from environment" |
48 | 51 | ||
49 | #include "libbb.h" | 52 | #include "libbb.h" |
50 | 53 | ||
@@ -54,8 +57,9 @@ int env_main(int argc UNUSED_PARAM, char **argv) | |||
54 | unsigned opts; | 57 | unsigned opts; |
55 | llist_t *unset_env = NULL; | 58 | llist_t *unset_env = NULL; |
56 | 59 | ||
57 | opts = getopt32long(argv, "+iu:*", | 60 | opts = getopt32long(argv, "+i0u:*", |
58 | "ignore-environment\0" No_argument "i" | 61 | "ignore-environment\0" No_argument "i" |
62 | "null\0" No_argument "0" | ||
59 | "unset\0" Required_argument "u" | 63 | "unset\0" Required_argument "u" |
60 | , &unset_env | 64 | , &unset_env |
61 | ); | 65 | ); |
@@ -90,8 +94,9 @@ int env_main(int argc UNUSED_PARAM, char **argv) | |||
90 | 94 | ||
91 | if (environ) { /* clearenv() may set environ == NULL! */ | 95 | if (environ) { /* clearenv() may set environ == NULL! */ |
92 | char **ep; | 96 | char **ep; |
97 | opts = (opts & 2) ? 0 : '\n'; | ||
93 | for (ep = environ; *ep; ep++) { | 98 | for (ep = environ; *ep; ep++) { |
94 | puts(*ep); | 99 | printf("%s%c", *ep, opts); |
95 | } | 100 | } |
96 | } | 101 | } |
97 | 102 | ||