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

Alexey Slynko slynko at elizabet.tronet.ru
Fri Sep 30 07:06:48 PDT 2005


On Fri, 30 Sep 2005, Simon 'corecode' Schubert wrote:

Date: Fri, 30 Sep 2005 11:38:33 +0200
From: Simon 'corecode' Schubert <corecode at xxxxxxxxxxxx>
Newsgroups: dragonfly.submit
Subject: Re: [PATCH] corrected setenv|putenv rc checking (bin)
Alexey Slynko wrote:
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	29 Sep 2005 00:48:06 -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;
I still think this shouldn't abort.
I still think that ls is not an exception of rule


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	29 Sep 2005 01:02:35 -0000
@@ -316,7 +317,8 @@
 			if (vp == &vmpath || (vp == &vmail && ! mpathset()))
 				chkmail(1);
 			if ((vp->flags & VEXPORT) && localevar(s)) {
-				putenv(s);
+				if (putenv(s) != 0)
+					err(1, "putenv: cannot set %s", s);
 				setlocale(LC_ALL, "");
 			}
 			INTON;
@@ -332,7 +334,8 @@
 	INTOFF;
 	*vpp = vp;
 	if ((vp->flags & VEXPORT) && localevar(s)) {
-		putenv(s);
+		if (putenv(s) != 0)
+			err(1, "putenv: cannot set %s", s);
 		setlocale(LC_ALL, "");
 	}
 	INTON;
@@ -553,7 +556,8 @@
  						vp->flags |= flag;
 						if ((vp->flags & VEXPORT) && 
localevar(vp->text)) {
-							putenv(vp->text);
+							if (putenv(vp->text) 
!= 0)
+								err(1, 
"putenv: cannot set %s", vp->text);
 							setlocale(LC_ALL, 
"");
 						}
 						goto found;
no!  don't collapse my shell if it can't allocate an env var!  set $? and 
output a warning.  You don't expect the shell to collapse if it can't exec a 
binary, right?

$ /bin/ehco foo
/bin/ehco: Command not found.
Login: _

WTF?
Can't reproduce it. Can you explain, how it can be reproduced?





More information about the Submit mailing list