bash - 使用非标准名称取消设置 bash 函数变量

标签 bash sh unset bash-function

我可能在获取 shell 的 bash 脚本中有这个函数

function suman{
     echo "using suman function"
}

如果我打电话

unset suman

事情似乎按预期进行

但是如果我有这个作为我的功能:

function suman-inspect {
     echo "using suman-inspect function"
}

那如果我打电话

unset suman-inspect

unset "suman-inspect"

我收到这条消息:

bash: unset: `suman-inspect': not a valid identifier

如何取消设置这个变量?

最佳答案

经过更多的研究,似乎

unset -f "suman-inspect"

会起作用。这是令人惊讶的,因为 unset suman 确实有效,并且成功取消了 suman 函数的设置(据我所知)。

关于bash - 使用非标准名称取消设置 bash 函数变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40812914/

相关文章:

bash - bash 中的 $ 是什么?

linux - 使用 iwatch 监视目录更改 - 获取新文件名而不是完整路径?

bash - 如何在工作区中运行带参数的 MATLAB 自定义脚本

linux - sh Linux 中的预期回显截断

bash - 关于流重定向 : `cat x > y <` 的 bash 谜语

bash - GNU 并行忽略管道命令

linux - 通过读取命令在 POSIX 兼容的 shell 脚本中解析 cal 输出

php - 取消设置对象 PHP 的所有实例

PHP 数组未设置

php - 部分删除/销毁 $_SESSION 数据? PHP