Re: wrong behaviour when unsetting/setting some variables

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

 



Op 29-02-2024 om 12:29 schreef Christoph Anton Mitterer:
On Tue, 2024-02-27 at 02:53 -0500, Lawrence Velázquez wrote:
That's my understanding:  Environment variables must have values
(even empty ones), so unset shell variables cannot be placed into
the environment.  One might propose that a valueless environment
variable could be represented as "name", but the standard requires
that environment strings contain a "=".

And yet:
The shell shall give the export attribute to the variables
corresponding to the specified names, which shall cause them to be
in the environment of subsequently executed commands.

would IMO mean that export attribute alone decides whether it's
exported or not - not whether it has a set value.

No shell currently behaves like that, and it would make no sense, as 'unset' and 'empty value' are distinct states.

However, the variable will be exported once a value is subsequently assigned to it, without the need to re-invoke 'export'.

$ unset foo; export foo; printenv foo  # not yet actually exported
$ foo=bar; printenv foo                # but now it is

--
||	modernish -- harness the shell
||	https://github.com/modernish/modernish
||
||	KornShell lives!
||	https://github.com/ksh93/ksh





[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux