Skip to content

fix(cli): expand bundled short options containing -l/-i with -c - #112

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/bundled-short-options-login-interactive
Sep 16, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/bundled-short-options-login-interactive

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Bash merges short invocation options: bash -lc 'cmd' is login + command, bash -ilc 'cmd' is interactive + login + command. This is a widely used form (login shells in scripts, CI wrappers, su -l -c-style flows).

Problem

The combined-option expander in run_args only whitelisted set-style flags (e/u/x/C/f/h/n/B/r) plus s/o alongside c. A bundle containing l or i failed the whitelist and fell through untouched:

  • niu -lc 'echo hi' → bash: -l: invalid option + usage, exit 2
  • niu -ic 'echo hi' → bash: -ic: No such file or directory, exit 1 (treated as a script name)

GNU bash 5.3.0 handles both (-lc runs a login shell with the command string; -ic runs the string interactively).

Fix

Whitelist l and i in the expander and emit them as their own flags — both already have dedicated arms in the option loop (-l sets the login-shell marker, -i sets interactive), so no new plumbing is needed. Bundles now work in any order: -lc, -cl, -ilc, -cil, …

Verification

  • cargo build --release, then rubash -lc 'echo hello' → executes, rc=0; -ilc/-cl same.
  • Regression behavior unchanged: -ce 'x', -l -c 'x', -o posix -c 'x' still work.

Bash merges short invocation options, so `niu -lc 'cmd'` means
login + command and `bash -ilc` means interactive + login + command.
The combined-option expander only whitelisted set-style flags
(e/u/x/C/f/h/n/B/r) plus s/o, so a bundle containing `l` or `i`
failed: `-lc` fell through to the short-option loop and died with
"-l: invalid option" + usage, and `-ic` was treated as a script
name ("No such file or directory").

Whitelist `l` and `i` in the expander and emit them as their own
flags (both already have dedicated arms in the option loop).
@caomengxuan666
caomengxuan666 merged commit 8b81c75 into master Sep 16, 2026
3 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/bundled-short-options-login-interactive branch September 24, 2026 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant