Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does running "echo $-" output "himBH" on the bash shell?

Tags:

bash

shell

macos

I'm using macOS. When I open a bash shell and execute echo $-, it outputs himBH. What does that mean?

like image 434
starkshang Avatar asked Feb 16 '16 12:02

starkshang


People also ask

What does $- mean in bash?

$- (dollar hyphen) bash parameter is used to get current option flags specified during the invocation, by the set built-in command or set by the bash shell itself.

What does echo stand for in bash?

Echoes (prints) the exit value for the previous command. If it failed it will be different than zero ( 0 ).


1 Answers

It shows your Builtin Set Flags. man bash then look for SHELL BUILTIN COMMANDS and then look for the set subsection. You will find the meanings of all those flags:

h: Remember the location of commands as they are looked up for execution.  This is enabled by default.
i: interactive
m: Monitor mode.  Job control is enabled
B: The shell performs brace expansion (see Brace Expansion above).  This is on by default
H: Enable !  style history substitution.  This option is on by default when the shell is interactive.
like image 141
mauro Avatar answered Sep 28 '22 07:09

mauro