Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 May 2001 21:29:38 -0700
From:      Dima Dorfman <dima@unixfreak.org>
To:        hackers@freebsd.org
Subject:   Fixing documented bug in env(1)
Message-ID:  <20010601042938.B31243E2F@bazooka.unixfreak.org>

next in thread | raw e-mail | index | archive | help
Hi folks,

Right now, env(1) can't be used to run programs with an equals sign in
them for obvious reasons (if it isn't obvious, read the man page :-).
Although this is a documented shortcoming, it's quite unnecessary
given how easy it is to fix it.  Any objections to allowing '--' to
mean "end of env. variable assignments"?

Patch attached below.

Thanks,

					Dima Dorfman
					dima@unixfreak.org


Index: env/env.c
===================================================================
RCS file: /stl/src/FreeBSD/src/usr.bin/env/env.c,v
retrieving revision 1.5
diff -u -r1.5 env.c
--- env/env.c	1999/08/27 08:59:31	1.5
+++ env/env.c	2001/06/01 04:27:41
@@ -73,6 +73,8 @@
 		}
 	for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv)
 		(void)setenv(*argv, ++p, 1);
+	if (*argv && strcmp(*argv, "--") == 0)
+		++argv;
 	if (*argv) {
 		execvp(*argv, argv);
 		err(1, "%s", *argv);
@@ -86,6 +88,6 @@
 usage()
 {
 	(void)fprintf(stderr,
-	    "usage: env [-] [-i] [name=value ...] [command]\n");
+	    "usage: env [-] [-i] [name=value ...] [--] [command]\n");
 	exit(1);
 }
Index: printenv/printenv.1
===================================================================
RCS file: /stl/src/FreeBSD/src/usr.bin/printenv/printenv.1,v
retrieving revision 1.10
diff -u -r1.10 printenv.1
--- printenv/printenv.1	2001/05/30 03:15:39	1.10
+++ printenv/printenv.1	2001/06/01 04:27:41
@@ -34,7 +34,7 @@
 .\"	@(#)printenv.1	8.1 (Berkeley) 6/6/93
 .\" $FreeBSD: src/usr.bin/printenv/printenv.1,v 1.10 2001/05/30 03:15:39 dd Exp $
 .\"
-.Dd June 6, 1993
+.Dd May 29, 2001
 .Dt PRINTENV 1
 .Os BSD 3
 .Sh NAME
@@ -47,6 +47,7 @@
 .Op Fl
 .Op Fl i
 .Op Ar name=value ...\&
+.Op --
 .Op Ar command
 .Sh DESCRIPTION
 .Nm Printenv
@@ -80,6 +81,18 @@
 .Ar name  ,
 with a value of
 .Ar value  .
+If the argument
+.Ql --
+is found,
+.Nm env
+will assume that the argument(s) following it are part of
+.Ar command ,
+instead of
+.Ar name=value
+pairs,
+even if they have the
+.Ql =
+symbol in them.
 .Pp
 The options are as follows:
 .Bl -tag -width indent
@@ -130,7 +143,3 @@
 .Nm
 command appeared in
 .Bx 3.0 .
-.Sh BUGS
-.Nm Env
-doesn't handle commands with equal (``='') signs in their
-names, for obvious reasons.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010601042938.B31243E2F>