help-bash
[Top][All Lists]
Advanced

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

Re: feature todo .. be able to unset vars at assignment stage , without


From: Zachary Santer
Subject: Re: feature todo .. be able to unset vars at assignment stage , without unset util , for coding language fair extendment
Date: Thu, 22 Feb 2024 10:40:12 -0500

On Wed, Feb 21, 2024 at 4:38 PM Chet Ramey <chet.ramey@case.edu> wrote:

>
> OK. What's the use case for this?
>

If you want to set environment variables in a given command's environment,
you can just place those assignments in front of the command you want to
run. If there's an exported variable present in the script, or in the
interactive shell, that you don't want present in the command's
environment, your options are:
a) call the command using the env command with the --unset flag, or
b) turn off the variable's export attribute before calling the command and
then turn it back on afterwards.

Having a way for bash itself to unset a variable only within the
environment of a given command, within the call to that command, might be
useful. How often will the behavior of any given utility differ between
having an environment variable set to the empty string versus having it
unset? Of course, env isn't able to run a builtin.

I don't know what kind of syntax you could use for this, and my use case
here might actually conflict with what Alex is suggesting.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]