Repository navigation
fix(#585): invocation-name-aware help - bash/sh --help print the GNU usage contract - #596
Merged
Merged
Conversation
…ract GNU bash answers --help with the show_shell_usage(stdout, extra=1) contract - version line, usage pair naming the invoked shell, long-option table, shell-options block, footer (shell.c:477-482, 2057-2103) - while rubash printed the product help under every name. The help surface now forks on argv[0]: bash/-bash and sh/-sh spellings print the GNU usage form (rc 0, stdout; the login dash and the sh-vs-bash name reach the usage lines, oracle-verified against WSL bash 5.3.0(1)-release), and any other invocation name (rubash, niu, ...) keeps the product help byte for byte. The version line honestly carries the engine's own BASH_VERSION + machtype in GNU's `version %s-(%s)` shape, and the long-option table is the engine's accepted LONG_OPTIONS set - no aspirational entries. -h stays GNU hashall (oracle: bash -h -c 'echo hi' executes; GNU -h is not a help word). The fork lives entirely in the engine keyed off argv[0], so the niubash bash/sh forwarder shims need no change, and no Windows-only resources are referenced on the unix cross-compile lanes. tests: tests/issue585_invocation_aware_help_regressions.rs pins the bash/-bash/sh GNU forms (exact bytes vs the oracle shape), the rc and stream contract, and the rubash/niu product-help regression. closes #585
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.
fix(#585): invocation-name-aware help — bash/sh
--helpprint the GNU usage contractProblem
Under the
bash/shinvocation names,--helpprinted the product help(setup/font/doctor/plugin/self-update verbs — none of them bash options),
byte-identical to
niu --help. GNU bash answers--helpwith theshow_shell_usage(stdout, extra=1)contract: a version line, the usagepair naming the invoked shell, the long-option table, the shell-options
block, and the footer (shell.c:477-482, 2057-2103), rc 0, on stdout.
The fork (engine layer, keyed off argv[0])
parse_long_options'shelparm now forks on the invocation name(argv[0] basename,
.exestripped,-login marker kept in thedisplay name):
bash/-bash→ the GNU usage contract withbash(resp.-bash)in the usage and `Type ...' lines,
sh/-sh→ the same shape with the sh name (GNU prints theinvoked name; oracle:
exec -a sh bash --help→Usage:\tsh ...),to before (owner constraint:
niu --helpkeeps the full producthelp; the GNU usage appears ONLY under the bash/sh names).
GNU bash, version %s-(%s)shape (shell.c:2071): todayGNU bash, version 5.3.0(1)-release-(x86_64-pc-msys).LONG_OPTIONSset —the same 16 entries the usage-error block already prints; no
aspirational entries. The Shell options block is byte-identical to the
existing usage-error contract.
src/bin/bash.rsuntouched): the forklives entirely in the engine, keyed off argv[0], exactly where the
fix(shim): forward the sh invocation name so the host honors its GNU contract #504/[bug] script-file argument open failure exits 1 instead of 127 (ENOENT) / 126 (EISDIR etc.) — shell.c open_shell_script EX_NOTFOUND/EX_NOINPUT unmapped #262 execution-contract forwarding lands once the host resolves
the invocation name.
cross-compile lanes (
cargo check --target x86_64-unknown-linux-gnuetc.) compile the same plain-string tables.
Why
-his unchanged-hstays GNU hashall. Oracle (WSL bash 5.3.0(1)-release):bash -h -c 'echo hi'executes the command (rc 0, printshi) andbash -hwith a stdin script runs it — GNU's-his not a help word(only the long option
--helpsetswant_initial_help, shell.c:477).Making
-hprint usage would breakbash -h -c ...-style invocations;the launcher-owned
-hsurface (product help underniu) is unchangedper the owner constraint.
Verification
tests/issue585_invocation_aware_help_regressions.rs: bash/-bash/shinvocations assert the exact GNU form (byte-for-byte against the WSL
5.3.0(1)-release oracle shape, version line excepted), rc 0, stdout
not stderr;
rubashand aniu-named binary assert the product helpstays byte-identical.
RUST_TEST_THREADS=1 cargo test --no-fail-fast) failureset vs the master baseline: bidirectional
commempty (the 10pre-existing cli_tests/regression failures match one-to-one).
RUSTFLAGS=-D warnings cargo checkclean; test-crate warning setidentical to master (windows and linux targets).
cargo fmtclean; UTF-8 boundary hygiene lane clean.closes #585