Izy-
Izy-

Reputation: 1163

What does $- mean in Bash?

I was playing around on the shell when by mistake, I typed echo $- and I got the result himBH. Immediately, I tried all other combinations of symbols along with the $ sign but with no luck. I read this post but I didn't fully understand it. Can someone please epxlain what they mean by 'shell options' and what himBH is supposed to mean?

Much thanks!

Upvotes: 35

Views: 22595

Answers (1)

anubhava
anubhava

Reputation: 786001

$- prints The current set of options in your current shell.

himBH means following options are enabled:

  • H - histexpand: when history expansion is enabled
  • m - monitor: when job control is enabled
  • h - hashall: Locate and remember (hash) commands as they are looked up for execution
  • B - braceexpand: when brace expansion is enabled
  • i - interactive: when current shell is interactive

Upvotes: 67

Related Questions