Commit f9bd4143 authored by KOBAYASHI Shuji's avatar KOBAYASHI Shuji

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"]
  ```
parent a89d15cd
......@@ -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 ?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment