How do I unset a variable in the fish shell?

最后都变了- 提交于 2019-12-03 06:27:53

问题


In bash I can unset a variable with

unset myvar

In fish I get

fish: Unknown command 'unset'

What's the equivalent for unset in fish.


回答1:


Fish uses options on the set command to manipulate shell variables.

Unset a variable with the -e or --erase option.

set -e myvar 

Additionally you can define a function

function unset
  set --erase $argv
end

funcsave unset

or an abbreviation

abbr --add unset 'set --erase'

or an alias in ~/.config/fish/config.fish

alias unset 'set --erase'


来源:https://stackoverflow.com/questions/30703860/how-do-i-unset-a-variable-in-the-fish-shell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!