Repository navigation
fix(cli): expand bundled short options containing -l/-i with -c - #112
Merged
caomengxuan666 merged 1 commit intoSep 16, 2026
Merged
Conversation
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
deleted the
fix/bundled-short-options-login-interactive
branch
September 24, 2026 23:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_argsonly whitelisted set-style flags (e/u/x/C/f/h/n/B/r) pluss/oalongsidec. A bundle containinglorifailed the whitelist and fell through untouched:niu -lc 'echo hi'→bash: -l: invalid option+ usage, exit 2niu -ic 'echo hi'→bash: -ic: No such file or directory, exit 1 (treated as a script name)GNU bash 5.3.0 handles both (
-lcruns a login shell with the command string;-icruns the string interactively).Fix
Whitelist
landiin the expander and emit them as their own flags — both already have dedicated arms in the option loop (-lsets the login-shell marker,-isets interactive), so no new plumbing is needed. Bundles now work in any order:-lc,-cl,-ilc,-cil, …Verification
cargo build --release, thenrubash -lc 'echo hello'→ executes, rc=0;-ilc/-clsame.-ce 'x',-l -c 'x',-o posix -c 'x'still work.