ruby-changes:23833
From: akr <ko1@a...>
Date: Sun, 3 Jun 2012 20:12:30 +0900 (JST)
Subject: [ruby-changes:23833] akr:r35884 (trunk): * process.c (rb_proc_exec_e): extended version of rb_proc_exec() to
akr 2012-06-03 20:12:20 +0900 (Sun, 03 Jun 2012) New Revision: 35884 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35884 Log: * process.c (rb_proc_exec_e): extended version of rb_proc_exec() to call execle(). (rb_proc_exec): use rb_proc_exec_e(). (rb_exec_err): use rb_proc_exec_e(). Modified files: trunk/ChangeLog trunk/process.c trunk/test/ruby/test_process.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 35883) +++ ChangeLog (revision 35884) @@ -1,3 +1,10 @@ +Sun Jun 3 20:10:52 2012 Tanaka Akira <akr@f...> + + * process.c (rb_proc_exec_e): extended version of rb_proc_exec() to + call execle(). + (rb_proc_exec): use rb_proc_exec_e(). + (rb_exec_err): use rb_proc_exec_e(). + Sun Jun 3 19:47:18 2012 NARUSE, Yui <naruse@r...> * thread.c (vm_living_thread_num): suppress a warning. Index: process.c =================================================================== --- process.c (revision 35883) +++ process.c (revision 35884) @@ -1160,14 +1160,14 @@ } #ifdef __native_client__ -int -rb_proc_exec(const char *str) +static int +rb_proc_exec_e(const char *str, VALUE envp_str) { rb_notimplement(); } #else -int -rb_proc_exec(const char *str) +static int +rb_proc_exec_e(const char *str, VALUE envp_str) { #ifndef _WIN32 const char *s = str; @@ -1210,7 +1210,10 @@ exit(status); #else before_exec(); - execl("/bin/sh", "sh", "-c", str, (char *)NULL); + if (envp_str) + execle("/bin/sh", "sh", "-c", str, (char *)NULL, (char **)RSTRING_PTR(envp_str)); + else + execl("/bin/sh", "sh", "-c", str, (char *)NULL); preserving_errno(after_exec()); #endif return -1; @@ -1226,7 +1229,7 @@ *a = NULL; } if (argv[0]) { - ret = proc_exec_v(argv, NULL, Qfalse); + ret = proc_exec_v(argv, NULL, envp_str); } else { errno = ENOENT; @@ -1237,6 +1240,12 @@ } #endif +int +rb_proc_exec(const char *str) +{ + return rb_proc_exec_e(str, Qfalse); +} + enum { EXEC_OPTION_PGROUP, EXEC_OPTION_RLIMIT, @@ -2527,7 +2536,7 @@ } if (argc == 0) { - rb_proc_exec(prog); + rb_proc_exec_e(prog, e->envp_str); } else { rb_proc_exec_ne(argc, argv, prog, e->envp_str); Index: test/ruby/test_process.rb =================================================================== --- test/ruby/test_process.rb (revision 35883) +++ test/ruby/test_process.rb (revision 35884) @@ -309,6 +309,18 @@ assert_equal(nil, ENV["mgg"], "[ruby-core:44093] [ruby-trunk - Bug #6249]") end + def test_execopts_env_single_word + with_tmpchdir {|d| + open("test_execopts_env_single_word.rb", "w") {|f| + f.puts "print ENV['hgga']" + } + system({"hgga"=>"ugu"}, RUBY, + :in => 'test_execopts_env_single_word.rb', + :out => 'test_execopts_env_single_word.out') + assert_equal('ugu', File.read('test_execopts_env_single_word.out')) + } + end + def test_execopts_unsetenv_others h = {} MANDATORY_ENVS.each {|k| e = ENV[k] and h[k] = e} -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/