This question already has an answer here:
How can you ask bash for the current options?
(1个答案)
三年前关闭。
今天我发现变量“$-”是一个随机字符串,但我不知道它代表什么。
➜  ~ echo $-
569JNRTXZghikms

我无法更改值:
➜  ~ -='sss'
zsh: command not found: -=sss
➜  ~

在一个码头里是:
➜  ~ docker  run --rm -ti ubuntu
root@7084255fd54e:/# echo $-
himBH

或:
➜  ~ docker  run --rm -ti alpine ash
/ # echo $-
smi

它的价值与系统有关吗?

最佳答案

$-为shell设置的当前选项。
the Bash Reference Manual
使用“+”而不是“-”将关闭这些选项。这个
选项也可以在调用shell时使用。当前集合
的选项可以在$-中找到。
剩下的N个参数是位置参数并被赋值,
按顺序,设置为$1,$2,…$N。特殊参数#设置为N。
除非提供无效选项,否则返回状态始终为零。

关于bash - bash或zsh中的“$-”是什么意思? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37428556/

10-14 17:15
查看更多