Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

[ruby-dev:29124] Re: [ BUG ] $0 cannot keep the given string: msg#00205

lang.ruby.devel

Subject: [ruby-dev:29124] Re: [ BUG ] $0 cannot keep the given string

なかだです。

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>
Google Custom Search

Recently Viewed:
solaris.opensol...    editors.vim/200...    web.turbogears....    jakarta.ant.dev...    mathematics.max...    text.unicode.ge...    lang.ruby.core/...    xfce.announce/2...    network.centeri...    php.cvs.pear/20...    user-groups.lin...    kde.devel.quant...    file-systems.ar...    redhat.fedora.t...    apple.fink.auto...    gnome.orbit.gen...    qplus.devel/200...    culture.transpo...    video.dri.user/...    operators.nanog...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive 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

Navigation