How to unset environment variable

From razwiki
Revision as of 14:23, 17 December 2021 by Razzi (talk | contribs) (Created page with "In <code>bash</code>: bash-3.2$ echo $EDITOR vim bash-3.2$ unset EDITOR bash-3.2$ echo $EDITOR In <code>fish</code>: Downloads $ echo $EDITOR vim Downloads $ set -...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

In bash:

bash-3.2$ echo $EDITOR
vim
bash-3.2$ unset EDITOR
bash-3.2$ echo $EDITOR

In fish:

Downloads $ echo $EDITOR
vim
Downloads $ set -e EDITOR
Downloads $ echo $EDITOR

A common use case is that editing the .profile does not remove environment variables that have been commented out, so they need to be erased manually. Perhaps a fancy script could parse the .profile and find commented out settings, then unset them.