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

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

Post by KC » Sat, 31 Dec 2005 21:21:08



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

 
 
 

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

Post by Etienne Marai » Sat, 31 Dec 2005 21:36:06


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


> 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


--
Etienne Marais
Cosmic Link
South Africa

 
 
 

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

Post by KC » Sat, 31 Dec 2005 22:26:37


Gotcha, Thanks
 
 
 

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

Post by Chris F.A. Johnso » Sat, 31 Dec 2005 22:32:12



> 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   |    <http://cfaj.freeshell.org>
   Shell Scripting Recipes:     |  My code in this post, if any,
   A Problem-Solution Approach  |          is released under the
   2005, Apress                 |     GNU General Public Licence

 
 
 

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

Post by KC » Sat, 31 Dec 2005 22:46:19


Hi Chris,

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

KC