summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-07 14:12:08 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-07 14:12:08 +0000
commitd5ecd17aeedae091ddda0f1a26c67f9902243ab1 (patch)
tree393d932608de4f5dc8933518182dcac74bd52ef2 /ruby.c
parent34bb945c40beb9998e3e33ed603a5841826128c5 (diff)
Add Process.argv0.
* ruby.c (Process.argv0): New method to return the original value of $0. [Feature #8696] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ruby.c b/ruby.c
index 6c9061c..d93f5fd 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1205,7 +1205,8 @@ opt_enc_index(VALUE enc_name)
return i;
}
-#define rb_progname (GET_VM()->progname)
+#define rb_progname (GET_VM()->progname)
+#define rb_orig_progname (GET_VM()->orig_progname)
VALUE rb_argv0;
static VALUE
@@ -1834,7 +1835,7 @@ void
ruby_script(const char *name)
{
if (name) {
- rb_progname = rb_external_str_new(name, strlen(name));
+ rb_orig_progname = rb_progname = rb_external_str_new(name, strlen(name));
rb_vm_set_progname(rb_progname);
}
}
@@ -1846,7 +1847,7 @@ ruby_script(const char *name)
void
ruby_set_script_name(VALUE name)
{
- rb_progname = rb_str_dup(name);
+ rb_orig_progname = rb_progname = rb_str_dup(name);
rb_vm_set_progname(rb_progname);
}
@@ -1914,6 +1915,7 @@ ruby_prog_init(void)
rb_define_hooked_variable("$0", &rb_progname, 0, set_arg0);
rb_define_hooked_variable("$PROGRAM_NAME", &rb_progname, 0, set_arg0);
+ rb_define_module_function(rb_mProcess, "argv0", proc_argv0, 0);
rb_define_module_function(rb_mProcess, "setproctitle", proc_setproctitle, 1);
/*