相关疑难解决方法(0)

“--”(双破折号)是什么意思?

--compgen命令中看到使用过。

例如:

compgen -W "foo bar baz" -- b
Run Code Online (Sandbox Code Playgroud)

里面的意思是什么--

command-line shell utilities syntax

659
推荐指数
5
解决办法
25万
查看次数

命令行选项是否在选项名称和值之间使用等号?

刚开始使用kubectl作为一个例子,我注意到,kubectl run --image nginx ...kubectl run --image=nginx ...双方的工作。

对于一般的命令行程序,是否有关于选项名称和值之间是否允许/需要等号的规则?

options

11
推荐指数
2
解决办法
2192
查看次数

在脚本末尾删除所有变量是一个好习惯吗?

在脚本末尾删除 shell 脚本中使用的变量是否好。

rm -rf $abc
rm -rf $def
Run Code Online (Sandbox Code Playgroud)

或者

unset $abc
unset $def
Run Code Online (Sandbox Code Playgroud)

等等。

这实际上是一个好习惯吗?

shell bash shell-script rm variable

1
推荐指数
2
解决办法
6798
查看次数

命名的 bash 函数参数

一直想知道这一点,但从未完全调查过 - 有没有办法在 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 shell-script

1
推荐指数
1
解决办法
5862
查看次数

标签 统计

bash ×2

shell ×2

shell-script ×2

command-line ×1

options ×1

rm ×1

syntax ×1

utilities ×1

variable ×1