On Mon, Oct 30, 2017 at 7:31 PM, 'Andy Wokula' via vim_dev
<[email protected]> wrote:
> Am 26.09.2016 um 00:10 schrieb Luc Hermitte (Vim Github Repository):
>>
>> When an environment variable isn't set, `exists()` return false. We can
>> assign a value to the variable with `:let`, after which point it exists. But
>> we can't revert to an non-existent state (related to `unsetenv (3C)`)
>>
>> ```vim
>> call assert_false(exists('$FOOBAR'))
>> let $FOOBAR = 1
>> call assert_true(exists('$FOOBAR'))
>> unlet $FOOBAR
>> call assert_false(exists('$FOOBAR'))
>> ```
>
>
> At least on Windows, assigning the empty string "unlets" it.
>
> --
> Andy
OTOH, on Linux, after assigning the empty string, exists('$FOOBAR')
still returns 1, while ":unlet $FOOBAR" gives error E488: Trailing
characters.
The classical way to test for "empty or undefined" is
if ("X" . $FOOBAR) == "X"
which, AFAICT, returns true even if $FOOBAR is undefined (i.e. has
never been set in this environment).
Best regards,
Tony.
--
--
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/d/optout.