On 03/02/14 01:39, ZyX wrote:
If I do
vim -u NONE -c 'unlet $PATH'
I get “E488: Trailing characters” error.
That means that there is no way to get rid of environment variable after it was
set which may be essential if tools using variables check for their existence,
not for their contents (e.g. in tcsh scripts checking for emptyness and for
existence are different constructs and they are rarely checked both (and
non-existent variables expand to errors, not to empty values), it is also not
uncommon to write “if 'VARNAME' in os.environ:” or use EAFP principle in python
in which cases empty string is treated just like any other value).
It appears that we have two conflicting requirements here when only one
can be supported.
On the one hand we have ViM's current behaviour as pointed out by Bram:
On 03/02/14 02:54, Bram Moolenaar wrote:
>
> Historically environment variables cannot be deleted, only made empty.
> ...
> Note that Vim will consider a non-existing environment variable to be
> empty, it doesn't give an error for ":let s = $ASDFASDF".
While on the other we have the desire to be able to remove an environment
variable from the environment of the currently running ViM process, making
the ViM variable equivalent of that environment variable "non-existent".
The fact of the matter is that ViM's current behaviour, in considering a
"non-existent" environment variable as "defined but empty", means that
even if an "unlet" command on an environment variable were to exist it
still wouldn't give the desired effect, as any subsequent test on the unlet
variable would just yield an empty value, not "variable undefined" (which
is what is being called for).
Thus, as well as adding "unlet", as you would also have to modify the
fundamental way in which ViM environment variable handling works, this
kind of change could seriously upset all existing scripts and plug-ins.
However, in addition to the "unlet" command, if it were possible just to
modify the "exists()" function so that "exists($XXX)" returns Zero if XXX
is physically not in the environment and One if XXX is physically there,
regardless of its value, then unletting an environment variable and then
checking for its existence with "exists($XXX)" would solve the problem
(currently, "exists($XXX)" is the same as testing if $XXX is empty).
Furthermore, if only "exists()" is changed, while the impact to scripts
would still exist. the current behaviour of returning an empty string
value when accessing non-existent environment variables would be retained.
This would definitely be the lesser of two evils with regards to backward
compatibility.
Cheers,
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.