[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] The meaning of $-?
From: |
Eduardo A . Bustamante López |
Subject: |
Re: [Help-bash] The meaning of $-? |
Date: |
Thu, 16 Jan 2014 15:55:02 -0800 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Thu, Jan 16, 2014 at 05:29:41PM -0600, Peng Yu wrote:
> Hi,
>
> I don't quite understand this special parameters.
>
> `$-`
> : Expands to the current option flags as specified upon invocation,
> by the set builtin command, or those set by the shell itself (such as
> the -i option).
At the beginning of the bash manual, you'll find a section named
OPTIONS. This section describes command line short options (like -i
and -e) that bash accepts to modify its behavior.
For example, -i makes bash interactive (that's the 'i' in the
'himBH').
Also, there's a section that explains the ''set'' command, that looks
something like this:
| set [--abefhkmnptuvxBCEHPT] [-o option-name] [arg ...]
| set [+abefhkmnptuvxBCEHPT] [+o option-name] [arg ...]
| Without options, the name and value of each shell variable
| are displayed in a format that can be reused as input for
| setting or resetting the currently-set variables. Read-
| ...
And that lists options like -f, -e, -a, -m, and so on. For example, the -m
option stands for "monitor mode", or job control enabled in the shell
(the 'm' in the 'himBH' string).
> On my system, I see something like the following. Could anybody
> explain what it is? Thanks.
>
> ~$ echo $-
> himBH
This basically means that you have:
-h hashall,
-i interactive,
-m monitor mode,
-B brace expand,
-H histexpand,
enabled. You can read more about these specific options in the bash
manual.
You can imagine the uses that this parameter can have (figure out if
your script has a required option enabled, for example).
--
Eduardo Alan Bustamante López