summaryrefslogtreecommitdiff
path: root/lib/irb/lc
diff options
context:
space:
mode:
authorJeremy Evans <[email protected]>2022-09-17 02:25:15 +0900
committergit <[email protected]>2022-09-17 02:25:26 +0900
commitb07db967441161a84386bcbbb41d990a2f3ad31c (patch)
tree2cc325c7ad264443694dc7287da6cbace9d98fb8 /lib/irb/lc
parent64200990c4425ad3d104d4695dbe9cb3356555cd (diff)
[ruby/irb] Support --noscript option to not use first non-option argument as script
Also add --script option to turn the option back on. Previously there wasn't a way to get an interactive IRB session and access arguments provided on the command line. Additionally, handle `-` as script as stdin. In Unix-like tools, `-` means to take standard input instead of a file. This doesn't result in exactly the same output for: ``` echo 'p ARGV' > args.rb; irb args.rb a b c ``` and ``` echo 'p ARGV' | irb - a b c ``` Due to how irb handles whether stdin is a tty. However, this change allows use of `-` as a argument, instead of giving an unrecognized switch error. This required some small changes to context.rb (to handle `-` as standard input) and input-method.rb (to have FileInputMethod accept IO arguments in addition to strings). Implements [Feature #15371] https://github.com/ruby/irb/commit/4192683ba2
Diffstat (limited to 'lib/irb/lc')
-rw-r--r--lib/irb/lc/help-message2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/irb/lc/help-message b/lib/irb/lc/help-message
index 3405fa775f..5b23f4c41e 100644
--- a/lib/irb/lc/help-message
+++ b/lib/irb/lc/help-message
@@ -38,6 +38,8 @@ Usage: irb.rb [options] [programfile] [arguments]
--sample-book-mode, --simple-prompt
Set prompt mode to 'simple'.
--noprompt Don't output prompt.
+ --script Script mode (default, treat first argument as script)
+ --noscript No script mode (leave arguments in argv)
--single-irb Share self with sub-irb.
--tracer Show stack trace for each command.
--back-trace-limit n[=16]