diff options
author | Garance A Drosehn <gad@FreeBSD.org> | 2005-06-20 03:09:49 +0000 |
---|---|---|
committer | Garance A Drosehn <gad@FreeBSD.org> | 2005-06-20 03:09:49 +0000 |
commit | 212274c3b6152dacfd9ce8e0925e0ffe8377bb01 (patch) | |
tree | b7e70ff40bea23d6aa4824d7514bd45cec615791 /usr.bin/env | |
parent | f66e378b5e3da25c7e7b15eee442665ebd89adf5 (diff) | |
download | src-test2-212274c3b6152dacfd9ce8e0925e0ffe8377bb01.tar.gz src-test2-212274c3b6152dacfd9ce8e0925e0ffe8377bb01.zip |
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')
Notes
Notes:
svn path=/head/; revision=147491
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 b4753b0ce9b5..ebfdc98f308f 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); |