On Tue, Jun 06, 2017 at 01:09:09PM +0100, Stephane CHAZELAS wrote: > 2017-06-06 13:46:33 +0200, Joerg Schilling: > > Stephane Chazelas <stephane.chaze...@gmail.com> wrote:
> > > AFAICT the historical reason for "-" to also be the > > > end-of-option marker was that in the Bourne shell, options were > > > only considered in the first argument if it started with "-" > > > (and later, "+" as well). What follows the "-" is a list, > > > possibly empty of option letters (later sh +u-e was added > > > (though not sh -e+u), not sure why as it doesn't seem any option > > > ever gets enabled by default, so there should be any need to > > > turn them off on startup) > > I know of no shell that would suport any of those strings. > > The first letter decides whether it is an option, so '-' or '+' > > are permitted as the first letter. > > Any futher letter in the option string is handled as an option > > letter and '-' or '+' are not accepted. > [...] > Yes, you're right, it looks like the "-" in: > sh +u-e > is just ignored (or everything is ignored for all I can tell > with testing as there's nothing that can be turned off here). > More generally, given that there's no option enabled by default, > it looks like "sh +anything" is pointless, which is why I said > above "not sure why as it doesn't seem any option ever gets > enabled by default, so there should be any need to turn them off > on startup". Again, I suppose it's just because it shares the > same code as "set". In interactive mode, job control (-m) is enabled automatically. Some shells, such as FreeBSD sh, dash, mksh and heirloom-sh-050706, allow starting an interactive shell without job control using sh +m, while other shells, such as bash and ksh93, do not (the option is ignored). I use this feature in the FreeBSD sh testsuite to test interactive features without needing to set up a tty. Disabling job control as the first command is not a suitable alternative, since the harmful effects of a missing or improper tty (warning messages and stop signals) occur before the first command. -- Jilles Tjoelker