Commit 57a5b80b
57a5b80b06d0Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
spinel: support `--` to end CLI flag parsing
A leading `--` (before the .rb source) ends spinel's own flag parsing — the next token becomes the source. In -E mode any remaining tokens become the binary's ARGV.
`--` after the source name is left untouched (it shows up in ARGV verbatim, matching CRuby's `ruby script.rb -- foo`).
Fixes #835
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 57a5b80b06d0
- Parent
- 885048a6e745
spinelmodifiedView file
@@ -73,6 +73,28 @@
7373
--rbs) shift; RBS_DIR="$1"; shift ;;7474
--int-overflow=*) INT_OVERFLOW="${1#--int-overflow=}"; shift ;;7575
--int-overflow) shift; INT_OVERFLOW="$1"; shift ;;76+
--) # `--` ends spinel-flag parsing (issue #835).77+
# In -E (run) mode the remaining args become ARGV78+
# for the compiled binary; in compile mode the next79+
# token is treated as the source path (matching ruby).80+
shift81+
if [ "$RUN_MODE" -eq 1 ]; then82+
if [ -z "$SOURCE" ] && [ $# -gt 0 ]; then83+
SOURCE="$1"84+
shift85+
fi86+
break87+
fi88+
if [ -z "$SOURCE" ] && [ $# -gt 0 ]; then89+
SOURCE="$1"90+
shift91+
fi92+
# Anything left after the source is ignored in93+
# compile-only mode (matches ruby's behaviour where94+
# trailing args become ARGV — but spinel doesn't run95+
# the program here).96+
break97+
;;7698
-o) shift; OUTPUT="$1"; shift ;;7799
-O) shift; OPT_LEVEL="$1"; shift ;;78100
-e) shift