diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-05-07 14:31:19 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-05-07 14:31:19 +0800 |
| commit | fc247449e29b26f07a9c6ba84c6dfaf0c6369f46 (patch) | |
| tree | 033831e019fb5db1515df9288c63c8dbb976d390 /mrbgems/mruby-bin-mirb/tools/mirb/mirb.c | |
| parent | 72581696d35e8da79a3a9d606294602c83abdf9f (diff) | |
| parent | 0c01afc3c9d3ec95badb6c463288376908bf18d7 (diff) | |
| download | mruby-fc247449e29b26f07a9c6ba84c6dfaf0c6369f46.tar.gz mruby-fc247449e29b26f07a9c6ba84c6dfaf0c6369f46.zip | |
Merge pull request #4017 from mimaki/mruby-d-option
Add `-d` option for `mruby` and `mirb`.
Diffstat (limited to 'mrbgems/mruby-bin-mirb/tools/mirb/mirb.c')
| -rw-r--r-- | mrbgems/mruby-bin-mirb/tools/mirb/mirb.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c b/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c index a58a72e7d..5ea4df07e 100644 --- a/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +++ b/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c @@ -54,6 +54,7 @@ #include <mruby/proc.h> #include <mruby/compile.h> #include <mruby/string.h> +#include <mruby/variable.h> #ifdef ENABLE_READLINE @@ -219,6 +220,7 @@ is_code_block_open(struct mrb_parser_state *parser) struct _args { FILE *rfp; mrb_bool verbose : 1; + mrb_bool debug : 1; int argc; char** argv; }; @@ -228,6 +230,7 @@ usage(const char *name) { static const char *const usage_msg[] = { "switches:", + "-d Set $DEBUG to true (same as `mruby -d`)" "-v print version number, then run in verbose mode", "--verbose run in verbose mode", "--version print the version", @@ -254,6 +257,9 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args) item = argv[0] + 1; switch (*item++) { + case 'd': + args->debug = TRUE; + break; case 'v': if (!args->verbose) mrb_show_version(mrb); args->verbose = TRUE; @@ -413,6 +419,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)); #ifdef ENABLE_READLINE history_path = get_history_path(mrb); |
