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!
$- (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.
$1 means an input argument and -z means non-defined or empty. You're testing whether an input argument to the script was defined when running the script. Follow this answer to receive notifications.
In both cases, the -z flag is a parameter to the bash's "test" built-in (a built-in is a command that is built-into the shell, it is not an external command). The -z flag causes test to check whether a string is empty. Returns true if the string is empty, false if it contains something.
The echo command is used to display a line of text that is passed in as an argument. This is a bash command that is mostly used in shell scripts to output status to the screen or to a file.
$-
prints The current set of options in your current shell.
himBH
means following options are enabled:
H
- histexpand
m
- monitor
h
- hashall
B
- braceexpand
i
- interactive
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With