From jos@catnook.com  Fri Apr 16 21:54:31 2004
Return-Path: <jos@catnook.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 76EB516A4CE
	for <freebsd-gnats-submit@freebsd.org>; Fri, 16 Apr 2004 21:54:31 -0700 (PDT)
Received: from mail1.dslextreme.com (mail1.dslextreme.com [66.51.199.25])
	by mx1.FreeBSD.org (Postfix) with SMTP id 4A40543D58
	for <freebsd-gnats-submit@freebsd.org>; Fri, 16 Apr 2004 21:54:31 -0700 (PDT)
	(envelope-from jos@catnook.com)
Received: (qmail 11469 invoked from network); 17 Apr 2004 04:54:30 -0000
Received: from unknown (HELO w250.z064001178.sjc-ca.dsl.cnc.net) (66.218.45.239)
 by 192.168.8.25 with SMTP; Sat, 17 Apr 2004 04:54:30 +0000
Received: (qmail 1359 invoked by uid 1000); 17 Apr 2004 04:54:52 -0000
Message-Id: <20040417045452.1358.qmail@lizzy.catnook.com>
Date: 17 Apr 2004 04:54:52 -0000
From: Jos Backus <jos@catnook.com>
Reply-To: Jos Backus <jos@catnook.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Add `-u name' option to env(1)
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         65649
>Category:       bin
>Synopsis:       Add `-u name' option to env(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gad
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr 16 22:00:41 PDT 2004
>Closed-Date:    Tue May 13 22:49:41 UTC 2008
>Last-Modified:  Tue May 13 22:49:41 UTC 2008
>Originator:     Jos Backus
>Release:        FreeBSD 5.2-CURRENT i386
>Organization:
CatNook
>Environment:
System: FreeBSD lizzy.catnook.com 5.2-CURRENT FreeBSD 5.2-CURRENT #49: Fri Apr 16 20:26:49 PDT 2004 root@lizzy.catnook.com:/usr/obj/usr/src/sys/LIZZY i386

>Description:

	This patch adds the `-u name' option to env(1). For a rationale of why
	this is useful (besides compatibility with GNU coreutils), see this
	post:

	    http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=b083i6%2486c%241%40news5.svr.pol.co.uk

>How-To-Repeat:
>Fix:

--- env.c.orig	Fri Apr 16 21:16:44 2004
+++ env.c	Fri Apr 16 21:21:25 2004
@@ -64,13 +64,16 @@
 	char *cleanenv[1];
 	int ch;
 
-	while ((ch = getopt(argc, argv, "-i")) != -1)
+	while ((ch = getopt(argc, argv, "-iu:")) != -1)
 		switch(ch) {
 		case '-':
 		case 'i':
 			environ = cleanenv;
 			cleanenv[0] = NULL;
 			break;
+		case 'u':
+			unsetenv(optarg);
+			break;
 		case '?':
 		default:
 			usage();
@@ -90,6 +93,6 @@
 usage(void)
 {
 	(void)fprintf(stderr,
-	    "usage: env [-i] [name=value ...] [utility [argument ...]]\n");
+	    "usage: env [-i] [[-u name] ...] [name=value ...] [utility [argument ...]]\n");
 	exit(1);
 }
--- env.1.orig	Fri Apr 16 21:16:39 2004
+++ env.1	Fri Apr 16 21:41:17 2004
@@ -44,6 +44,7 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl i
+.Op Fl u Ar name
 .Op Ar name Ns = Ns Ar value ...
 .Op Ar utility Op Ar argument ...
 .Sh DESCRIPTION
@@ -71,6 +72,14 @@
 by
 .Nm
 is ignored completely.
+.It Fl u Ar name
+Execute the
+.Ar utility
+with
+.Ar name
+removed from the environment,
+if it was present in the environment inherited by
+.Nm  .
 .El
 .Pp
 If no utility is specified,
>Release-Note:
>Audit-Trail:

From: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
To: Jos Backus <jos@catnook.com>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: bin/65649: Add `-u name' option to env(1)
Date: Sat, 17 Apr 2004 13:36:19 -0400 (EDT)

 <<On 17 Apr 2004 04:54:52 -0000, Jos Backus <jos@catnook.com> said:
 
 > 	This patch adds the `-u name' option to env(1). For a rationale of why
 > 	this is useful (besides compatibility with GNU coreutils), see this
 > 	post:
 
 I can see the compatibility argument, but I think the utility is a bit
 of a stretch.  Anything that `env -u FOO COMMAND' can do, you can do
 with:
 
 (unset FOO; COMMAND)
 
 -GAWollman
 

From: Jos Backus <jos@catnook.com>
To: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/65649: Add `-u name' option to env(1)
Date: Sat, 17 Apr 2004 12:08:17 -0700

 On Sat, Apr 17, 2004 at 01:36:19PM -0400, Garrett Wollman wrote:
 > <<On 17 Apr 2004 04:54:52 -0000, Jos Backus <jos@catnook.com> said:
 > 
 > > 	This patch adds the `-u name' option to env(1). For a rationale of why
 > > 	this is useful (besides compatibility with GNU coreutils), see this
 > > 	post:
 > 
 > I can see the compatibility argument, but I think the utility is a bit
 > of a stretch.  Anything that `env -u FOO COMMAND' can do, you can do
 > with:
 > 
 > (unset FOO; COMMAND)
  
 But this also requires an extra shell invocation.
 
 Moreover, the patch doesn't increase the executable nor bloat the code so it's
 very unintrusive and gives us essentially free coreutils compatibility.
 
 Jos
 
 > -GAWollman
 
 -- 
 Jos Backus                       _/  _/_/_/      Sunnyvale, CA
                                 _/  _/   _/
                                _/  _/_/_/
                           _/  _/  _/    _/
 jos at catnook.com        _/_/   _/_/_/          require 'std/disclaimer'

From: Robin Breathe <robin@isometry.net>
To: freebsd-gnats-submit@FreeBSD.org
Cc: Jos Backus <jos@catnook.com>,
	Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
Subject: Re: bin/65649: Add `-u name' option to env(1)
Date: Fri, 12 Nov 2004 18:16:59 +0000

 The original justification link is no longer working, however I believe 
 the patch is justified. I found this PR in advance of implementing the 
 functionality myself.
 
 Setting the other valid arguments aside, it allows a shell-independent 
 method for adjusting a utility's environment.
 
 Consider the following:
 
 sh:
 # ( unset FOO; set BAR=BIM; COMMAND )
 # ( unset FOO; env BAR=BIM COMMAND )
 
 csh:
 # ( unsetenv FOO; setenv BAR BIM; COMMAND )
 # ( unsetenv FOO; env BAR=BIM COMMAND )
 
 patch:
 # env -u FOO BAR=BIM COMMAND
 
 Regards,
 Robin Breathe
 
Responsible-Changed-From-To: freebsd-bugs->gad 
Responsible-Changed-By: gad 
Responsible-Changed-When: Fri Jul 29 18:21:09 GMT 2005 
Responsible-Changed-Why:  
-  Given all that I have recently done to the `env' command, this seems 
like a reasonably useful option to also include.  For me, the primary 
use of `env' is to alter the environment before starting some program, 
*any* program, without requiring an extra invocation of /bin/sh just to 
get some tiny bit of work done.  This option for -u makes sense in that 
context (IMO).  I probably won't get to it in time for 6.0-release, but 
I will try to do it reasonably soon. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=65649 

From: Garance A Drosehn <gad@FreeBSD.org>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/65649: Add `-u name' option to env(1)
Date: Fri, 29 Jul 2005 17:58:53 -0400

 I just wrote:
 
     For me, the primary use of `env' is to alter the environment
     before starting some program, *any* program, without requiring
     an extra invocation of /bin/sh just to get some tiny bit of
     work done.
 
 I kept getting interrupted while writing (and re-writing) the
 above, and somewhere along the line I dropped the key point I
 wanted to make.  I meant: "using `env' to start some program
 via the #!-line on the first line of a shell script".  It's in
 *that* context, when used in the first line of a interpreted
 script, where this option makes a lot of sense to me.
 
 -- 
 Garance Alistair Drosehn     =      gad@gilead.netel.rpi.edu
 Senior Systems Programmer               or   gad@FreeBSD.org
 Rensselaer Polytechnic Institute;             Troy, NY;  USA

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/65649: commit references a PR
Date: Thu, 17 Apr 2008 23:17:25 +0000 (UTC)

 gad         2008-04-17 23:17:09 UTC
 
   FreeBSD src repository
 
   Modified files:
     usr.bin/env          env.1 env.c 
   Log:
   Add the '-u name' option to the env command, which will completely unset
   the given variable name (removing it from the environment, instead of
   just setting it to a null value).
   
   PR:             bin/65649
   MFC after:      2 weeks
   
   Revision  Changes    Path
   1.10      +21 -5     src/usr.bin/env/env.1
   1.20      +10 -3     src/usr.bin/env/env.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/65649: commit references a PR
Date: Tue, 13 May 2008 21:47:01 +0000 (UTC)

 gad         2008-05-13 21:46:50 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_7)
     usr.bin/env          env.1 env.c 
   Log:
   MFC *: Add the '-u name' option to the env command, which will completely
   unset the given variable name (removing it from the environment, instead
   of just setting it to a null value).
   
   [* = 1.10->1.11 env.1, 1.20 env.c]
   
   PR:             bin/65649
   
   Revision  Changes    Path
   1.9.10.1  +21 -5     src/usr.bin/env/env.1
   1.19.2.1  +10 -3     src/usr.bin/env/env.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: gad 
State-Changed-When: Tue May 13 22:47:33 UTC 2008 
State-Changed-Why:  
I added the '-u name' option to 8.x-current on April 17th, 2008, 
and MFC-ed it to 7.0-stable on May 13th.  At this point I have no 
plans to MFC it to 6.x, but I could be talked into doing that. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=65649 
>Unformatted:
