我--在compgen命令中看到使用过。
例如:
compgen -W "foo bar baz" -- b
Run Code Online (Sandbox Code Playgroud)
里面的意思是什么--?
刚开始使用kubectl作为一个例子,我注意到,kubectl run --image nginx ...和kubectl run --image=nginx ...双方的工作。
对于一般的命令行程序,是否有关于选项名称和值之间是否允许/需要等号的规则?
在脚本末尾删除 shell 脚本中使用的变量是否好。
rm -rf $abc
rm -rf $def
Run Code Online (Sandbox Code Playgroud)
或者
unset $abc
unset $def
Run Code Online (Sandbox Code Playgroud)
等等。
这实际上是一个好习惯吗?
一直想知道这一点,但从未完全调查过 - 有没有办法在 bash 中获取命名参数?
例如,我有这个:
function ql_maybe_fail {
if [[ "$1" == "true" ]]; then
echo "quicklock: exiting with 1 since fail flag was set for your 'ql_release_lock' command. "
exit 1;
fi
}
Run Code Online (Sandbox Code Playgroud)
是否有可能将它转换为这样的东西:
function ql_maybe_fail (isFail) {
if [[ "$isFail" == "true" ]]; then
echo "quicklock: exiting with 1 since fail flag was set for your 'ql_release_lock' command. "
exit 1;
fi
}
Run Code Online (Sandbox Code Playgroud) bash ×2
shell ×2
shell-script ×2
command-line ×1
options ×1
rm ×1
syntax ×1
utilities ×1
variable ×1