Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does $- mean in Bash? [duplicate]

Tags:

bash

shell

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!

like image 998
Izy- Avatar asked Mar 13 '17 05:03

Izy-


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 [- Z $1 mean in bash?

$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.

What is if [- Z in bash?

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.

What is echo $$ in bash?

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.


1 Answers

$- 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
like image 111
anubhava Avatar answered Nov 14 '22 02:11

anubhava