diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-09-10 18:12:38 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-09-10 18:12:38 +0900 |
| commit | c27e45193177b6e4d09d526a248af63c0961035a (patch) | |
| tree | 863c5082109295c880311b2abe1eefc4c748dc4d /mrbgems/mruby-bin-mirb/tools | |
| parent | c345fe432171cc2b90b614a0b44305b218090de6 (diff) | |
| parent | 9840e5352b2abf96235068f0e9d08f14b1d333cf (diff) | |
| download | mruby-c27e45193177b6e4d09d526a248af63c0961035a.tar.gz mruby-c27e45193177b6e4d09d526a248af63c0961035a.zip | |
Merge pull request #4933 from dearblue/variables
Fix take over file scope variables with `mruby` and `mirb` command
Diffstat (limited to 'mrbgems/mruby-bin-mirb/tools')
| -rw-r--r-- | mrbgems/mruby-bin-mirb/tools/mirb/mirb.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c b/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c index a0eeaf459..51ba3fd78 100644 --- a/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +++ b/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c @@ -495,12 +495,9 @@ main(int argc, char **argv) cxt = mrbc_context_new(mrb); -#ifndef DISABLE_MIRB_UNDERSCORE - decl_lv_underscore(mrb, cxt); -#endif - /* Load libraries */ for (i = 0; i < args.libc; i++) { + struct REnv *e; FILE *lfp = fopen(args.libv[i], "r"); if (lfp == NULL) { printf("Cannot open library file. (%s)\n", args.libv[i]); @@ -509,8 +506,16 @@ main(int argc, char **argv) } mrb_load_file_cxt(mrb, lfp, cxt); fclose(lfp); + e = mrb->c->cibase->env; + mrb->c->cibase->env = NULL; + mrb_env_unshare(mrb, e); + mrbc_cleanup_local_variables(mrb, cxt); } +#ifndef DISABLE_MIRB_UNDERSCORE + decl_lv_underscore(mrb, cxt); +#endif + cxt->capture_errors = TRUE; cxt->lineno = 1; mrbc_filename(mrb, cxt, "(mirb)"); |
