From: "nobu (Nobuyoshi Nakada)" Date: 2012-06-27T10:06:12+09:00 Subject: [ruby-dev:45859] [ruby-trunk - Feature #6651] Re: [ruby-cvs:43389] nobu:r36213 (trunk): popen: shell commands with envvar Issue #6651 has been updated by nobu (Nobuyoshi Nakada). Category set to core Target version set to 2.0.0 % Done changed from 0 to 100 ---------------------------------------- Feature #6651: Re: [ruby-cvs:43389] nobu:r36213 (trunk): popen: shell commands with envvar https://bugs.ruby-lang.org/issues/6651#change-27508 Author: nobu (Nobuyoshi Nakada) Status: Closed Priority: Normal Assignee: Category: core Target version: 2.0.0 =begin なかだです。 : At Mon, 25 Jun 2012 17:13:56 +0900, : Tanaka Akira wrote in [ruby-dev:45812]: とりあえず、現在はドキュメントと整合していない状態になっています。 すいません、自分で入れた仕様を忘れてました。 何がしたいかというと環境変数を指定してpopenをしたい、ただしコマ ンドはArrayにはわかれていない単一の文字列、といったところです。 例えばgitがページャーを実行するのにやっているようなことです。 IO.popen("LESS=RSs #{ENV['PAGER']}", "w") 今のところenvやexec optionを指定するのはcmdがArrayでないとできま せんが、Arrayの外に出してしまうというのを考えました。 IO.popen({"LESS"=>"RSs"}, ENV['PAGER'], "w") IO.popen({"LANG"=>"C"}, "ls non-existent", err:[:child, :out]) もちろんArrayを使っても同じです。 IO.popen({"LANG"=>"C"}, ["ls", "non-existent"], err:[:child, :out]) パッチは https://github.com/ruby/ruby/pull/134 です。 -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦 =end -- http://bugs.ruby-lang.org/