[PATCH] corrected setenv|putenv rc checking (bin)

Alexey Slynko slynko at elizabet.tronet.ru
Mon Oct 17 09:57:15 PDT 2005


Another corrected version of patch has attached. Shell behaviour has 
changed (now it uses built-in function error). But i stiil think, that ls 
should exit, if the setenv operation has failed. I think, there no differs 
between ls and smth like df.

Does anyone (except Simon) can say smth about that?



Index: date/date.c
===================================================================
RCS file: /mnt/share/dragonfly-cvs/src/bin/date/date.c,v
retrieving revision 1.13
diff -u -r1.13 date.c
--- date/date.c	20 Jul 2005 19:51:56 -0000	1.13
+++ date/date.c	30 Sep 2005 11:29:18 -0000
@@ -117,7 +117,8 @@
   			set_timezone = 1;
   			break;
   		case 'u':		/* do everything in UTC */
-			setenv("TZ", "UTC0", 1);
+			if (setenv("TZ", "UTC0", 1) != 0)
+				err(1, "setenv: cannot set TZ=UTC0");
   			break;
   		case 'v':
   			v = vary_append(v, optarg);
Index: df/df.c
===================================================================
RCS file: /mnt/share/dragonfly-cvs/src/bin/df/df.c,v
retrieving revision 1.5
diff -u -r1.5 df.c
--- df/df.c	7 Nov 2004 20:54:51 -0000	1.5
+++ df/df.c	30 Sep 2005 11:29:18 -0000
@@ -144,11 +144,13 @@
   		case 'b':
   				/* FALLTHROUGH */
   		case 'P':
-			putenv("BLOCKSIZE=512");
+			if (putenv("BLOCKSIZE=512") != 0)
+				err(1, "putenv: cannot set BLOCKSIZE=512");
   			hflag = 0;
   			break;
   		case 'g':
-			putenv("BLOCKSIZE=1g");
+			if (putenv("BLOCKSIZE=1g") != 0)
+				err(1, "putenv: cannot set BLOCKSIZE=1g");
   			hflag = 0;
   			break;
   		case 'H':
@@ -163,7 +165,8 @@
   			iflag = 1;
   			break;
   		case 'k':
-			putenv("BLOCKSIZE=1k");
+			if (putenv("BLOCKSIZE=1k") != 0)
+				err(1, "putenv: cannot set BLOCKSIZE=1k");
   			hflag = 0;
   			break;
   		case 'l':
@@ -172,7 +175,8 @@
   			vfslist = makevfslist(makenetvfslist());
   			break;
   		case 'm':
-			putenv("BLOCKSIZE=1m");
+			if (putenv("BLOCKSIZE=1m") != 0)
+				err(1, "putenv: cannot set BLOCKSIZE=1m");
   			hflag = 0;
   			break;
   		case 'n':
Index: ls/ls.c
===================================================================
RCS file: /mnt/share/dragonfly-cvs/src/bin/ls/ls.c,v
retrieving revision 1.14
diff -u -r1.14 ls.c
--- ls/ls.c	18 Sep 2005 18:01:49 -0000	1.14
+++ ls/ls.c	30 Sep 2005 11:29:18 -0000
@@ -221,7 +221,8 @@
   			fts_options |= FTS_COMFOLLOW;
   			break;
   		case 'G':
-			setenv("CLICOLOR", "", 1);
+			if (setenv("CLICOLOR", "", 1) != 0)
+				err(1, "setenv: cannot set CLICOLOR");
   			break;
   		case 'L':
   			fts_options &= ~FTS_PHYSICAL;
Index: sh/var.c
===================================================================
RCS file: /mnt/share/dragonfly-cvs/src/bin/sh/var.c,v
retrieving revision 1.8
diff -u -r1.8 var.c
--- sh/var.c	19 Apr 2005 05:18:19 -0000	1.8
+++ sh/var.c	1 Oct 2005 18:37:23 -0000
@@ -316,7 +316,8 @@
   			if (vp == &vmpath || (vp == &vmail && ! mpathset()))
   				chkmail(1);
   			if ((vp->flags & VEXPORT) && localevar(s)) {
-				putenv(s);
+				if (putenv(s) != 0)
+					error("putenv: cannot set %s", s);
   				setlocale(LC_ALL, "");
   			}
   			INTON;
@@ -332,7 +333,8 @@
   	INTOFF;
   	*vpp = vp;
   	if ((vp->flags & VEXPORT) && localevar(s)) {
-		putenv(s);
+		if (putenv(s) != 0)
+			error("putenv: cannot set %s", s);
   		setlocale(LC_ALL, "");
   	}
   	INTON;
@@ -553,7 +555,8 @@
   						vp->flags |= flag;
   						if ((vp->flags & VEXPORT) && localevar(vp->text)) {
-							putenv(vp->text);
+							if (putenv(vp->text) != 0)
+								error("putenv: cannot set %s", vp->text);
   							setlocale(LC_ALL, "");
   						}
   						goto found;




More information about the Submit mailing list