Definition of $-

Could someone please direct me to a link that gives the definitions for each of the letters from the results of the $- environment variable? It would be nice to know what shell options each of the letters represents, but I am specifically looking for the shell option for 'c' (lowercase c). Thank you.

Look at this thread for a start:
http://www.unix.com/unix-dummies-questions-answers/16746-parameter.html

Thank you for the reply. Sorry I haven't replied to this sooner but I've been out.

The link provided simply says to look at the man page for setting shell options for your particular shell. Well, that was the first thing I did when I was trying to figure this out. Unfortunately, the man pages for bash and ksh do not detail exactly which letter is associated with which shell option, and the letter is certainly not the first letter of the option itself. Some of them are obvious, like 'i' for interactive shell. Some I could figure out by turning off an option and looking to see what letter no longer existed when echoing $-. Unfortunately some of the options could not be determined this way. And I'm still trying to figure out what little 'c' means (in addition to some others).

did you mean this??

No. What I'm talking about is the following. If you echo $- from your interactive login shell you'll get something like this...

$ echo $-
himBCH

Each of these letters represent some option that is turned on within the shell. For example, the 'i' (lowercase i) indicates an interactive login shell. Now, if I execute this same echo command from within a script that my dtsession login process executes when logging in, I get the following...

echo $-
hBCc

What I would like to know is what shell option the 'c' (lowercase c represents).

I think thats what i posted
It passes -c option to shell whos explanation is given in man page of ksh or bash or ...

I could be wrong, but I believe that is simply a command line option that you send to the shell when you're starting it. It's not a "switch" (so to speak) that you turn on or off for shell options from within the shell. For example, expand_aliases is a shell option that you can turn on or off. That particular option however, doesn't seem to have a letter associated with it when you execute $-. So, to see it's state, you have to execute the shopt command.

Anyway, maybe I'm mistaken about this whole thing, but what purpose would it serve to have $- report that the shell was started with some command string. You still wouldn't know what the command was, only that some command was executed, and it really wouldn't represent a switch for some option that is enable/disabled.

The following applies to vanila ksh93t. The set of possible characters retuned by $- is:

DircabefhkmnpstuvxBCGEl

The meaning of these can be mostly inferred from the following defines which match the order of the above characters

SH_DICTIONARY, SH_INTERACTIVE, SH_RESTRICTED, SH_CFLAG,
SH_ALLEXPORT, SH_NOTIFY, SH_ERREXIT, SH_NOGLOB, SH_TRACKALL,
SH_KEYWORD, SH_MONITOR, SH_NOEXEC, SH_PRIVILEGED, SH_SFLAG, SH_TFLAG,
SH_NOUNSET, SH_VERBOSE,  SH_XTRACE, SH_BRACEEXPAND, SH_NOCLOBBER,
SH_GLOBSTARS, SH_RC, SH_LOGIN_SHELL

where SH_CFLAG, i.e. 'c', is set if ksh93 is involved with a "-c cmdstring" command line option.

/home/jmcnama> echo $-
isam
/home/jmcnama> ksh -c
echo $-
shc
exit
/home/jmcnama> echo $-
isam
/home/jmcnama> set -v
/home/jmcnama> echo $-
echo $-
ivsam
/home/jmcnama>

$- with a "c" in it means the shell was invoked with -c. Period. It does not tell you more than that. As you can see $- shows both invocation options, plus any options you set later on, in this example verbose was turned on interactively.

$- reflects BOTH options set at shell invocation and set later on. It is there to let you know what your runtime environment is like, -v for example, changes the way the running script appears to the user.

Ok, I guess I was wrong. That was exactly what I was looking for. The last two posts have given enough detail to explain to me what I was unable to find in any of the man pages.

So now I would like to know how you found this information. I have looked at both the ksh and bash man pages in detail and cannot find anything that explains the association of the individual letters with these options (at least for many of them). In fact, in the man pages I'm looking at on Solaris 10, there are no options that even begin with "SH_". And many of the options are ambiguous if you simply look at the first letter (i.e. hashall, histexpand, history; or emacs, errtrace; or physical, pipefail, posix, privileged; etc.)

Anyway, thanks for the info.

For ksh: the man page for ksh explains them. Look for the set keyword. ksh88 is what I showed you - this is what Solaris supports by default. fpMurphy showed you ksh93 - which is an add-on that you used to have to purchase separately.
There is also pdksh[number] a public domain version with newer features.

echo $SHELL

will tell you which one you are running.

The point is - there are some very different new features in ksh93, many of which are involved in PITA part of shell programming - string splitting, date arithmetic, etc. So your results may vary depending on your shell version.

The '$-' (and its friends $$, $? etc) are described in 'man ksh' under the header 'Parameters Set by Shell' (on Solaris). Here's the snippet:

  Parameters Set by Shell
     The following parameters are automatically set by the shell:

     #     The number of positional parameters in decimal.

     -     Flags supplied to the shell on invocation  or  by  the
           set command.

     ?     The decimal value returned by the last  executed  com-
           mand.

For the 'set -v' (and its friends), 'man ksh' and search for the 'Special Commands' header (on Solaris again). Here's the snippet of that:

Special Commands
...........
...........
     set [ +abCefhkmnopstuvx ] [ +o option ]... [ +A name ]  [ arg ...
           The flags for this command have meaning as follows:

           -A    Array assignment. Unsets the variable  name  and
                 assigns  values  sequentially from the list arg.
                 If +A is used, the variable name  is  not  unset
                 first.

           -a    All subsequent variables that  are  defined  are
                 automatically exported.

The information I provided is based on my knowledge of the ksh93 source code. It is not really documented fully in the man page or elsewhere.

Note that this information only pertains to ksh93 and not to pdksh, ksh88 or bash.