10

I'm normally well aware of the contents of $-. On a recent CentOS I get:

[grochmal@orion ~]$ echo $-
himBH

hmBH are all options from set, and i means that my shell is interactive.

Yet, on my Arch Linux I got:

[grochmal@haps ~]$ echo $-
himBHs

I cannot find anything useful in man bash and set -s gives me an error. What does that s stand for?

13

The -s option is the bash start call with -s, which means "source commands from "standard in". From the manual:

-s If the -s option is present, or if no arguments remain after option processing, then commands are read from the standard input. This option allows the positional parameters to be set when invoking an interactive shell.

It is very easy to test:

$ bash -c 'echo $-'
hBc

$ bash -sc 'echo $-'
hBcs

Starting a new shell for all previous bash versions doesn't set that option by default:

$ b32sh -li
$ echo $-
himBH

But it is in bash 4.4:

$ b44sh -li
$ echo $-
himBHs
  • And the second part explains why I got that on Arch. My CentOS' value for BASH_VERSION is 4.2.46(1)-release whilst on Arch is it 4.4.5(1)-release. – grochmal Dec 11 '16 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.