Skip to content

ksh --usage / set --usage output missing the + flag #1057

Open

Description

@stephane-chazelas
$ getopts "$(set --usage)" opt +f; echo "$opt"
?

Even though set does accept the +f option.

$ set --usage | cut -c1-72
[-1c?\n@(#)$Id: set (ksh 93u+m) 2026-02-10 $\n][--catalog?libshell][+NAM

That output is missing the + flag. Should be something like:

+[-1c?\n@(#)$Id: set (ksh 93u+m) 2026-02-10 $\n][--catalog?libshell][+NAM...

Or:

[-1+c?\n@(#)$Id: set (ksh 93u+m) 2026-02-10 $\n][--catalog?libshell][+NAM

Same for ksh93 itself that accepts +options.

According to gdb, that's the former that's passed to optget():

Breakpoint 1, optget (argv=argv@entry=0x5555556891e0,
    oopts=oopts@entry=0x555555623c20 <sh_optset> "+[-1c?\n@(#)$Id: set (ksh 93u+m) 2026-02-10 $\n][--catalog?libshell][+NAME?set - set/unset options and positional parameters][+DESCRIPTION?\bset\b sets or unsets options and positional parameters. Options"...) at src/lib/libast/misc/optget.c:4350

See also:

$ getopts +o opt --usage
o
$ getopts '+[o]' opt --usage
[o]
$ getopts '[-+][o]' opt --usage
[-+][o]

The + flag is preserved when passed using the extended interface. And:

$ getopts '+o(opt)' opt --usage
[-][o:opt]

That "legacy" o(opt) is translated to extended [-][o:opt] but the + flag is lost.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions