【发布时间】:2017-12-10 06:00:37
【问题描述】:
可以使用source <(grep = test.ini)从.ini文件中读取变量:
$ cat test.ini
[head]
shoulders=/hahaha/
knees=/lololol/
toes=/kekeke/
$ source <(grep = test.ini)
$ echo $shoulders
/hahaha/
$ echo $knees
/lololol/
$ echo $toes
/kekeke/
我可以手动清除从source <(grep = ...) 命令读取的变量,例如
$ unset toes
$ echo toes
但是有没有办法自动跟踪从source 命令添加的变量并将它们全部取消设置?
【问题讨论】:
-
是否允许重复使用ini文件?
-
像这样在
ini文件中获取资源可能不安全。 -
为什么获取 ini 文件不安全?
-
可以,重复使用ini文件就可以了。
标签: bash shell unix grep unset