|
|
Choosing A Webhost: |
[ruby-dev:29124] Re: [ BUG ] $0 cannot keep the given string: msg#00205lang.ruby.devel
なかだです。 At Mon, 24 Jul 2006 16:49:10 +0900, Hidetoshi NAGAI wrote in [ruby-dev:29123]: > > なんで$0にそんな長い文字列をセットしようとしているんでしょうか。 > > 外部のプロセスから見えるかどうかも環境次第なので、とくに拘る必 > > 要性は感じないのですが。 > > sandbox 内で別のスクリプト ( S とします) を稼働させようと > している状況を考えてください. > この S は単独でも動くスクリプトであり, > スクリプトで __FILE__ == $0 のような条件判断を行っています. > > __FILE__ は ruby 上で書き換えできませんので, > この S を期待通りに動かすためには,S の load の際に > 一時的に $0 を S のフルパスに変更してやる必要があります. 外部に見える必要がなくてスクリプト内部だけの問題であれば、 ext/extmk.rbのようにaliasで避けることはできます。 $progname = $0 alias $PROGRAM_NAME $0 alias $0 $progname これで、$PROGRAM_NAMEがコマンドラインに対応することになり、$0と $prognameは普通のグローバル変数になります。 -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [ruby-dev:29123] Re: [ BUG ] $0 cannot keep the given string, Hidetoshi NAGAI |
|---|---|
| Next by Date: | [ruby-dev:29125] Re: [ BUG ] $0 cannot keep the given string, Hidetoshi NAGAI |
| Previous by Thread: | [ruby-dev:29123] Re: [ BUG ] $0 cannot keep the given string, Hidetoshi NAGAI |
| Next by Thread: | [ruby-dev:29125] Re: [ BUG ] $0 cannot keep the given string, Hidetoshi NAGAI |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |