What"s the meaning of $- (minus sign, not underscore)

What"s the meaning of $- (minus sign, not underscore)

am 30.12.2005 13:21:08 von kc

Hi,

I'm using bash under Linux. The special shell parameter $- in my
environment is:

# echo $-
himBH
#

I know the 'i' means interactive shell. What's h,m,B,H mean ?
I can't find the explaination by "man bash". Anyone know the answer ?

Thanks
KC
kccheng@LinuxDAQ-Labs.org

Re: What"s the meaning of $- (minus sign, not underscore)

am 30.12.2005 13:36:06 von Etienne Marais

Those appear to be shell 'set' values

Snippets from `info bash --index-search=set`

`-h'
Locate and remember (hash) commands as they are looked up for
execution. This option is enabled by default.

`-m'
Job control is enabled (*note Job Control::).

`-B'
The shell will perform brace expansion (*note Brace
Expansion::). This option is on by default.

`-H'
Enable `!' style history substitution (*note History
Interaction::). This option is on by default for interactive
shells.

Using `+' rather than `-' causes these options to be turned off.
The options can also be used upon invocation of the shell. The
current set of options may be found in `$-'.

KC wrote:

> Hi,
>
> I'm using bash under Linux. The special shell parameter $- in my
> environment is:
>
> # echo $-
> himBH
> #
>
> I know the 'i' means interactive shell. What's h,m,B,H mean ?
> I can't find the explaination by "man bash". Anyone know the answer ?
>
> Thanks
> KC
> kccheng@LinuxDAQ-Labs.org



--
Etienne Marais
Cosmic Link
South Africa

Re: What"s the meaning of $- (minus sign, not underscore)

am 30.12.2005 14:26:37 von kc

Gotcha, Thanks

Re: What"s the meaning of $- (minus sign, not underscore)

am 30.12.2005 14:32:12 von cfajohnson

On 2005-12-30, KC wrote:
> Hi,
>
> I'm using bash under Linux. The special shell parameter $- in my
> environment is:
>
> # echo $-
> himBH
> #
>
> I know the 'i' means interactive shell. What's h,m,B,H mean ?
> I can't find the explaination by "man bash". Anyone know the answer ?

$ sman() { LESS="$LESS${2:+ +/$2}" man $1; }
$ sman bash 'Special Parameters'

Special Parameters
The shell treats several parameters specially. These parameters may
only be referenced; assignment to them is not allowed.
..........
- Expands to the current option flags as specified upon invoca-
tion, by the set builtin command, or those set by the shell
itself (such as the -i option).


$ help set
.....
-h Remember the location of commands as they are looked up.
.....
-m Job control is enabled.
.....
-B the shell will perform brace expansion
.....
-H Enable ! style history substitution. This flag is on


--
Chris F.A. Johnson, author |
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence

Re: What"s the meaning of $- (minus sign, not underscore)

am 30.12.2005 14:46:19 von kc

Hi Chris,

Thanks. And your sman() is really smart :-) I like it.

KC