fix(run): accept - as the stdin script argument#39
Merged
ralyodio merged 1 commit intoJul 26, 2026
Conversation
`moshcode run - < script.mosh` is documented in README.md and handled explicitly by readScript(), but the option parser treated the bare `-` as an unknown option and exited 1 before it could be used. Exclude `-` from the leading-dash check so it falls through to the positional argument, where readScript() already reads stdin. Unknown options such as --bogus still exit 1 as before.
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.
The documented stdin form
moshcode run - < script.moshexits 1 withunknown option -.Reproduce
Cause
readScript()already handles the bare-(bin/moshcode.mjs:37):But the option parser rejects it first (
bin/moshcode.mjs:289), because-starts with a dash and no positional has been seen yet:So the stdin path is unreachable from the CLI. It is documented in two places:
README.md:164(moshcode run - < script.mosh # pipe/paste from stdin) and the comment atbin/moshcode.mjs:56.Fix
Exclude the bare
-from the leading-dash check so it falls through topositional, wherereadScript()picks it up.Verification
Added
run - reads the script from stdintotest/run-options.test.mjs. It fails on master (not ok 88) and passes with the fix. Full suite: 146/146 pass, up from 145 baseline.