mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fix ARGV value in mruby command (regression by #4827)
#### Before this patch: ``` $ bin/mruby -e 'p ARGV' a b ["bin/mruby", "-e", "p ARGV", "a", "b"] ``` #### After this patch: ``` $ bin/mruby -e 'p ARGV' a b ["a", "b"] ```
This commit is contained in:
@@ -39,6 +39,11 @@ assert '$0 value' do
|
||||
assert_equal '"-e"', `#{cmd('mruby')} -e #{shellquote('p $0')}`.chomp
|
||||
end
|
||||
|
||||
assert 'ARGV value' do
|
||||
assert_mruby(%{["ab", "cde"]\n}, "", true, %w[-e p(ARGV) ab cde])
|
||||
assert_mruby("[]\n", "", true, %w[-e p(ARGV)])
|
||||
end
|
||||
|
||||
assert('float literal') do
|
||||
script, bin = Tempfile.new('test.rb'), Tempfile.new('test.mrb')
|
||||
File.write script.path, 'p [3.21, 2e308.infinite?, -2e308.infinite?]'
|
||||
|
||||
@@ -189,8 +189,8 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
|
||||
}
|
||||
}
|
||||
|
||||
argc = opts->argc; argv = opts->argv;
|
||||
if (args->cmdline == NULL) {
|
||||
argc = opts->argc; argv = opts->argv;
|
||||
if (*argv == NULL) args->rfp = stdin;
|
||||
else {
|
||||
args->rfp = strcmp(argv[0], "-") == 0 ?
|
||||
|
||||
Reference in New Issue
Block a user