diff options
| author | Hiroshi Mimaki <[email protected]> | 2018-05-02 20:52:02 +0900 |
|---|---|---|
| committer | Hiroshi Mimaki <[email protected]> | 2018-05-02 20:52:02 +0900 |
| commit | 1d16646506ff7bc95d501deaee67740b08b218b5 (patch) | |
| tree | 01b58abff8ffb0f58006f0ef4e89e27b40dfc1e3 /mrbgems/mruby-bin-mruby | |
| parent | 028e34d3452acd1eb5602b78ff5c52f4dbb8a1eb (diff) | |
| download | mruby-1d16646506ff7bc95d501deaee67740b08b218b5.tar.gz mruby-1d16646506ff7bc95d501deaee67740b08b218b5.zip | |
Add `-d` option for `mruby` and `mirb`.
Diffstat (limited to 'mrbgems/mruby-bin-mruby')
| -rw-r--r-- | mrbgems/mruby-bin-mruby/bintest/mruby.rb | 7 | ||||
| -rw-r--r-- | mrbgems/mruby-bin-mruby/tools/mruby/mruby.c | 6 |
2 files changed, 13 insertions, 0 deletions
diff --git a/mrbgems/mruby-bin-mruby/bintest/mruby.rb b/mrbgems/mruby-bin-mruby/bintest/mruby.rb index b6b090185..3f6f3755d 100644 --- a/mrbgems/mruby-bin-mruby/bintest/mruby.rb +++ b/mrbgems/mruby-bin-mruby/bintest/mruby.rb @@ -58,3 +58,10 @@ RUBY assert_equal "NilClass", `#{cmd('mruby')} #{script.path}` assert_equal 0, $?.exitstatus end + +assert('mruby -d option') do + o = `#{cmd('mruby')} -e #{shellquote('p $DEBUG')}>&1` + assert_equal o, "false\n" + o = `#{cmd('mruby')} -d -e #{shellquote('p $DEBUG')}>&1` + assert_equal o, "true\n" +end diff --git a/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c b/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c index 61d4cde94..0db2c3f37 100644 --- a/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +++ b/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c @@ -27,6 +27,7 @@ struct _args { mrb_bool mrbfile : 1; mrb_bool check_syntax : 1; mrb_bool verbose : 1; + mrb_bool debug : 1; int argc; char** argv; }; @@ -38,6 +39,7 @@ usage(const char *name) "switches:", "-b load and execute RiteBinary (mrb) file", "-c check syntax only", + "-d Set debugging flags (set $DEBUG to true)" "-e 'command' one line of script", "-v print version number, then run in verbose mode", "--verbose run in verbose mode", @@ -78,6 +80,9 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args) case 'c': args->check_syntax = TRUE; break; + case 'd': + args->debug = TRUE; + break; case 'e': if (item[0]) { goto append_cmdline; @@ -199,6 +204,7 @@ main(int argc, char **argv) } } mrb_define_global_const(mrb, "ARGV", ARGV); + mrb_gv_set(mrb, mrb_intern_lit(mrb, "$DEBUG"), mrb_bool_value(args.debug)); c = mrbc_context_new(mrb); if (args.verbose) |
