NetBSD-Bugs archive

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

bin/58780: env(1) lacks any way to unset specific environment variables in subprocess



>Number:         58780
>Category:       bin
>Synopsis:       env(1) lacks any way to unset specific environment variables in subprocess
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 28 13:30:00 +0000 2024
>Originator:     Taylor R Campbell
>Release:        current, 10, 9, ...
>Organization:
The EnvBSD Foundation
>Environment:
>Description:
`env FOO=BAR cmd args' runs a command with the environment variable FOO set to BAR.  And `env -i FOO=BAR cmd args' does similarly with all other environment variables unset.  But if FOO is already set in the environment, there is no way to use env to run a command with just FOO unset and all other environment variables set.

Various other operating systems have agreed on using `env -u FOO ...' to request unsetting an environment variable:

- GNU coreutils: https://www.gnu.org/software/coreutils/manual/html_node/env-invocation.html#index-_002du-16
- FreeBSD: https://man.freebsd.org/cgi/man.cgi?query=env&apropos=0&sektion=0&manpath=FreeBSD+14.1-RELEASE+and+Ports&arch=default&format=html
- OpenBSD: https://man.openbsd.org/env.1
- macOS: https://ss64.com/mac/env.html

I think we should adopt this.
>How-To-Repeat:
Find a context, like `git clone ext::"..."', that takes a command line that is executed directly with execve rather than passed through a shell for interpretation, where it is necessary to unset an environment variable but it can't be done with a shell fragment like (unset FOO; exec ...).
>Fix:
Yes, please!



Home | Main Index | Thread Index | Old Index