diff options
author | gad <gad@FreeBSD.org> | 2005-06-20 03:09:49 +0000 |
---|---|---|
committer | gad <gad@FreeBSD.org> | 2005-06-20 03:09:49 +0000 |
commit | 4e1c4de27a0ad5eb26df6fc78a2305992d15de4e (patch) | |
tree | b7e70ff40bea23d6aa4824d7514bd45cec615791 /usr.bin/env | |
parent | cd436d6b803f08c5ec23a9512ebc13744b51e2af (diff) | |
download | FreeBSD-src-4e1c4de27a0ad5eb26df6fc78a2305992d15de4e.zip FreeBSD-src-4e1c4de27a0ad5eb26df6fc78a2305992d15de4e.tar.gz |
Move the code that clears the environment when `-i' is specified, so it that
it does not happen until all single-letter options are processed. This will
be important for the -S option, which will be coming soon.
Approved by: re (blanket `env')
Diffstat (limited to 'usr.bin/env')
-rw-r--r-- | usr.bin/env/env.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/env/env.c b/usr.bin/env/env.c index b4753b0..ebfdc98 100644 --- a/usr.bin/env/env.c +++ b/usr.bin/env/env.c @@ -64,16 +64,14 @@ main(int argc, char **argv) { char **ep, *p, **parg; char *cleanenv[1]; - int ch; + int ch, want_clear; + want_clear = 0; while ((ch = getopt(argc, argv, "-iv")) != -1) switch(ch) { case '-': case 'i': - environ = cleanenv; - cleanenv[0] = NULL; - if (env_verbosity) - fprintf(stderr, "#env clearing environ\n"); + want_clear = 1; break; case 'v': env_verbosity++; @@ -85,6 +83,12 @@ main(int argc, char **argv) default: usage(); } + if (want_clear) { + environ = cleanenv; + cleanenv[0] = NULL; + if (env_verbosity) + fprintf(stderr, "#env clearing environ\n"); + } for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv) { if (env_verbosity) fprintf(stderr, "#env setenv:\t%s\n", *argv); |