Skip to content

argument-less -O/+O errors (rc 2) where GNU lists the shopt table (rc 0) — sibling of the fixed -o case #780

Closed

Description

@caomengxuan666

Summary

Argument-less -o was fixed in #778 (now prints the option table, rc 0, matching GNU). Its sibling was left unreported and is still divergent:

$ rubash +O     # and: rubash -O
# rubash: rc 2  (invalid option / missing argument)
# GNU 5.3.0: prints the shopt table (set +o behaviour), rc 0

GNU bash's parse_shell_options (shell.c, the -O/+O arm) routes an argument-less -O/+O to the shopt listing exactly as -o/+o route to list_minus_o_opts. Verified against GNU bash 5.3.0 (file-based invocation); found during the #705 sweep and left untouched there for minimality.

Shape note

The engine route and the ShellInvocation route both error today, so the fix belongs beside the -o handling added in #778 (ShellInvocation records the request; the option-application step emits the table).

Activity

  1. caomengxuan666 commented on Oct 17, 2026

    @caomengxuan666
    MemberAuthor

    修了,提交 3f2275a。

    按 #778 的 -o/+o 同路处理:

    • ShellInvocation 加 list_shopt_options: Option<bool>,-O(false)走 name<TAB>on|off,+O(true)走 shopt -u|-s name。
    • 新增 Executor::print_shopt_options_listing / ShellInvocation::write_shopt_options_listing,字节直接来自 shopt / shopt -p 的内建表,不另写一份格式。
    • 两条解析路径都改了:引擎的 run_args(src/main.rs)和 parse_post_c_option。-O <name> / +O <name> 的行为不变。

    验证:-O 输出与 rubash -c shopt 逐字节相同,+O 与 rubash -c 'shopt -p' 相同,rc 0。回归测试 argument_less_capital_o_prints_the_shopt_listing 就用这个不变量断言,不依赖 GNU 在场。

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions