Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/env Do use putenv(3) to handle the provided strings ...



details:   https://anonhg.NetBSD.org/src/rev/468f35e7e5ef
branches:  trunk
changeset: 758065:468f35e7e5ef
user:      njoly <njoly%NetBSD.org@localhost>
date:      Sat Oct 16 11:13:52 2010 +0000

description:
Do use putenv(3) to handle the provided strings directly, instead of
setenv(3) which need string splitting and later reassembly.

diffstat:

 usr.bin/env/env.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (32 lines):

diff -r 93755906b5b5 -r 468f35e7e5ef usr.bin/env/env.c
--- a/usr.bin/env/env.c Sat Oct 16 10:41:50 2010 +0000
+++ b/usr.bin/env/env.c Sat Oct 16 11:13:52 2010 +0000
@@ -35,7 +35,7 @@
 
 #ifndef lint
 /*static char sccsid[] = "@(#)env.c    8.3 (Berkeley) 4/2/94";*/
-__RCSID("$NetBSD: env.c,v 1.18 2010/10/15 19:35:08 jschauma Exp $");
+__RCSID("$NetBSD: env.c,v 1.19 2010/10/16 11:13:52 njoly Exp $");
 #endif /* not lint */
 
 #include <err.h>
@@ -54,7 +54,7 @@
 int
 main(int argc, char **argv)
 {
-       char **ep, *p;
+       char **ep;
        char *cleanenv[1];
        int ch;
 
@@ -72,8 +72,8 @@
                        usage();
                }
 
-       for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv)
-               (void)setenv(*argv, ++p, 1);
+       for (argv += optind; *argv && strchr(*argv, '=') != NULL; ++argv)
+               (void)putenv(*argv);
 
        if (*argv) {
                /* return 127 if the command to be run could not be found; 126



Home | Main Index | Thread Index | Old Index