# Code Review: \_\_FILE\_\_ and $PROGRAM\_NAME paths

**URL:** <https://www.ruby-forum.com/t/code-review-file-and-program-name-paths/166011>\
**Category:** IronRuby\
**Created:** [April 21, 2009, 12:38am UTC](https://www.ruby-forum.com/t/code-review-file-and-program-name-paths/166011 "2009-04-21T00:38:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsoho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8baadc/32.png) [@jsoho](https://www.ruby-forum.com/u/jsoho)\
**Post date:** [April 21, 2009, 12:38am UTC](https://www.ruby-forum.com/t/code-review-file-and-program-name-paths/166011/1 "2009-04-21T00:38:12Z")

</div>

[http://github.com/jschementi/ironruby/commit/3ef1b6ac9718d0c55796c2818da797ea8bab7275](http://github.com/jschementi/ironruby/commit/3ef1b6ac9718d0c55796c2818da797ea8bab7275)

Makes **FILE** and $PROGRAM\_NAME (and $0) have canonicalized paths when  
Ruby is hosted from ir.exe. However, **FILE** is not messed with when  
including a file via require/load. Fixes  
[http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=545](http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=545).

---

<div class="post-metadata">

**Author:** ![jsoho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8baadc/32.png) [@jsoho](https://www.ruby-forum.com/u/jsoho)\
**Post date:** [April 21, 2009, 4:02am UTC](https://www.ruby-forum.com/t/code-review-file-and-program-name-paths/166011/2 "2009-04-21T04:02:24Z")

</div>

Comment left on Github:

Can you move the fixtures up a level and combine them? (Put them in  
rubyspec/fixtures instead of rubyspec/command\_line/fixtures and  
rubyspec/language/fixtures)

Also, shouldn’t we move Glob.CanonicalizePath to a more central  
location, then use that central location for both the hosting and the  
Glob implementation? Seems like this couples the hosting API to Glob,  
which doesn’t seem good.  
Other than that it looks good.

JD

From: Jimmy S.  
Sent: Monday, April 20, 2009 3:37 PM  
To: removed\_email\_address@domain.invalid  
Cc: IronRuby External Code R.  
Subject: Code Review: **FILE** and $PROGRAM\_NAME paths

[http://github.com/jschementi/ironruby/commit/3ef1b6ac9718d0c55796c2818da797ea8bab7275](http://github.com/jschementi/ironruby/commit/3ef1b6ac9718d0c55796c2818da797ea8bab7275)

Makes **FILE** and $PROGRAM\_NAME (and $0) have canonicalized paths when  
Ruby is hosted from ir.exe. However, **FILE** is not messed with when  
including a file via require/load. Fixes  
[http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=545](http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=545).

---

<div class="post-metadata">

**Author:** ![jsoho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8baadc/32.png) [@jsoho](https://www.ruby-forum.com/u/jsoho)\
**Post date:** [April 22, 2009, 2:20am UTC](https://www.ruby-forum.com/t/code-review-file-and-program-name-paths/166011/3 "2009-04-22T02:20:05Z")

</div>

[http://github.com/jschementi/ironruby/commit/57d18b591ba9cba92923864936f359de446e2f97](http://github.com/jschementi/ironruby/commit/57d18b591ba9cba92923864936f359de446e2f97)

Code Review changes

- Moves command\_line/fixtures/file\* and language/fixtures/file\* to  
fixtures/

- Create RubyUtils.CanonicalizePath, to dependency on  
IronRuby.Builtins.Glob from IronRuby.Hosting

Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/command\_line/fixtures/file.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/command\_line/fixtures/file/sub.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/command\_line/program\_name\_spec.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/fixtures/file.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/fixtures/file/sub.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/file\_spec.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/fixtures/file.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/fixtures/file/sub.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/predefined\_spec.rb  
\* Merlin/Main/Languages/Ruby/Ruby/Builtins/Glob.cs  
\* Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyCommandLine.cs  
\* Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyOptionsParser.cs  
\* Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyUtils.cs

From: Jim D.  
Sent: Monday, April 20, 2009 6:53 PM  
To: Jimmy S.; removed\_email\_address@domain.invalid  
Cc: IronRuby External Code R.  
Subject: RE: Code Review: **FILE** and $PROGRAM\_NAME paths

Comment left on Github:

Can you move the fixtures up a level and combine them? (Put them in  
rubyspec/fixtures instead of rubyspec/command\_line/fixtures and  
rubyspec/language/fixtures)

Also, shouldn’t we move Glob.CanonicalizePath to a more central  
location, then use that central location for both the hosting and the  
Glob implementation? Seems like this couples the hosting API to Glob,  
which doesn’t seem good.  
Other than that it looks good.

JD

From: Jimmy S.  
Sent: Monday, April 20, 2009 3:37 PM  
To: removed\_email\_address@domain.invalid  
Cc: IronRuby External Code R.  
Subject: Code Review: **FILE** and $PROGRAM\_NAME paths

[http://github.com/jschementi/ironruby/commit/3ef1b6ac9718d0c55796c2818da797ea8bab7275](http://github.com/jschementi/ironruby/commit/3ef1b6ac9718d0c55796c2818da797ea8bab7275)

Makes **FILE** and $PROGRAM\_NAME (and $0) have canonicalized paths when  
Ruby is hosted from ir.exe. However, **FILE** is not messed with when  
including a file via require/load. Fixes  
[http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=545](http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=545).

---

<div class="post-metadata">

**Author:** ![jsoho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8baadc/32.png) [@jsoho](https://www.ruby-forum.com/u/jsoho)\
**Post date:** [April 22, 2009, 8:40pm UTC](https://www.ruby-forum.com/t/code-review-file-and-program-name-paths/166011/4 "2009-04-22T20:40:00Z")

</div>

[http://github.com/jschementi/ironruby/commit/43514f8f9e980ba22dfb5b8661e5633661f50d1f](http://github.com/jschementi/ironruby/commit/43514f8f9e980ba22dfb5b8661e5633661f50d1f)

Remove Glob.CanonicalizePath (in favor of RubyUtils.CanonicalizePath)

- 

Merlin/Main/Languages/Ruby/Libraries.LCA\_RESTRICTED/Builtins/FileOps.cs

- 

```
     Merlin/Main/Languages/Ruby/Ruby/Builtins/Glob.cs

```

From: Tomas M.  
Sent: Tuesday, April 21, 2009 5:38 PM  
To: Jimmy S.; Jim D.; removed\_email\_address@domain.invalid  
Cc: IronRuby External Code R.  
Subject: RE: Code Review: **FILE** and $PROGRAM\_NAME paths

Could you remove

public static MutableString/_!_/ CanonicalizePath(MutableString/_!_/  
path) {  
return RubyUtils.CanonicalizePath(path);  
}

from Glob and call RubyUtils directly wherever Glob.CanonicalizePath is  
used?

Other than that looks good.

Tomas

From: Jimmy S.  
Sent: Tuesday, April 21, 2009 5:19 PM  
To: Jim D.; removed\_email\_address@domain.invalid  
Cc: IronRuby External Code R.  
Subject: RE: Code Review: **FILE** and $PROGRAM\_NAME paths

[http://github.com/jschementi/ironruby/commit/57d18b591ba9cba92923864936f359de446e2f97](http://github.com/jschementi/ironruby/commit/57d18b591ba9cba92923864936f359de446e2f97)

Code Review changes

- Moves command\_line/fixtures/file\* and language/fixtures/file\* to  
fixtures/

- Create RubyUtils.CanonicalizePath, to dependency on  
IronRuby.Builtins.Glob from IronRuby.Hosting

Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/command\_line/fixtures/file.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/command\_line/fixtures/file/sub.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/command\_line/program\_name\_spec.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/fixtures/file.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/fixtures/file/sub.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/file\_spec.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/fixtures/file.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/fixtures/file/sub.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/predefined\_spec.rb  
\* Merlin/Main/Languages/Ruby/Ruby/Builtins/Glob.cs  
\* Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyCommandLine.cs  
\* Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyOptionsParser.cs  
\* Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyUtils.cs

From: Jim D.  
Sent: Monday, April 20, 2009 6:53 PM  
To: Jimmy S.; removed\_email\_address@domain.invalid  
Cc: IronRuby External Code R.  
Subject: RE: Code Review: **FILE** and $PROGRAM\_NAME paths

Comment left on Github:

Can you move the fixtures up a level and combine them? (Put them in  
rubyspec/fixtures instead of rubyspec/command\_line/fixtures and  
rubyspec/language/fixtures)

Also, shouldn’t we move Glob.CanonicalizePath to a more central  
location, then use that central location for both the hosting and the  
Glob implementation? Seems like this couples the hosting API to Glob,  
which doesn’t seem good.  
Other than that it looks good.

JD

From: Jimmy S.  
Sent: Monday, April 20, 2009 3:37 PM  
To: removed\_email\_address@domain.invalid  
Cc: IronRuby External Code R.  
Subject: Code Review: **FILE** and $PROGRAM\_NAME paths

[http://github.com/jschementi/ironruby/commit/3ef1b6ac9718d0c55796c2818da797ea8bab7275](http://github.com/jschementi/ironruby/commit/3ef1b6ac9718d0c55796c2818da797ea8bab7275)

Makes **FILE** and $PROGRAM\_NAME (and $0) have canonicalized paths when  
Ruby is hosted from ir.exe. However, **FILE** is not messed with when  
including a file via require/load. Fixes  
[http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=545](http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=545).

---

<div class="post-metadata">

**Author:** ![jsoho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8baadc/32.png) [@jsoho](https://www.ruby-forum.com/u/jsoho)\
**Post date:** [April 22, 2009, 8:40pm UTC](https://www.ruby-forum.com/t/code-review-file-and-program-name-paths/166011/5 "2009-04-22T20:40:01Z")

</div>

Looks good.

Tomas

From: Jimmy S.  
Sent: Wednesday, April 22, 2009 10:56 AM  
To: Tomas M.; Jim D.; removed\_email\_address@domain.invalid  
Cc: IronRuby External Code R.  
Subject: RE: Code Review: **FILE** and $PROGRAM\_NAME paths

[http://github.com/jschementi/ironruby/commit/43514f8f9e980ba22dfb5b8661e5633661f50d1f](http://github.com/jschementi/ironruby/commit/43514f8f9e980ba22dfb5b8661e5633661f50d1f)

Remove Glob.CanonicalizePath (in favor of RubyUtils.CanonicalizePath)

- 

Merlin/Main/Languages/Ruby/Libraries.LCA\_RESTRICTED/Builtins/FileOps.cs

- 

```
     Merlin/Main/Languages/Ruby/Ruby/Builtins/Glob.cs

```

From: Tomas M.  
Sent: Tuesday, April 21, 2009 5:38 PM  
To: Jimmy S.; Jim D.; removed\_email\_address@domain.invalid  
Cc: IronRuby External Code R.  
Subject: RE: Code Review: **FILE** and $PROGRAM\_NAME paths

Could you remove

public static MutableString/_!_/ CanonicalizePath(MutableString/_!_/  
path) {  
return RubyUtils.CanonicalizePath(path);  
}

from Glob and call RubyUtils directly wherever Glob.CanonicalizePath is  
used?

Other than that looks good.

Tomas

From: Jimmy S.  
Sent: Tuesday, April 21, 2009 5:19 PM  
To: Jim D.; removed\_email\_address@domain.invalid  
Cc: IronRuby External Code R.  
Subject: RE: Code Review: **FILE** and $PROGRAM\_NAME paths

[http://github.com/jschementi/ironruby/commit/57d18b591ba9cba92923864936f359de446e2f97](http://github.com/jschementi/ironruby/commit/57d18b591ba9cba92923864936f359de446e2f97)

Code Review changes

- Moves command\_line/fixtures/file\* and language/fixtures/file\* to  
fixtures/

- Create RubyUtils.CanonicalizePath, to dependency on  
IronRuby.Builtins.Glob from IronRuby.Hosting

Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/command\_line/fixtures/file.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/command\_line/fixtures/file/sub.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/command\_line/program\_name\_spec.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/fixtures/file.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/fixtures/file/sub.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/file\_spec.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/fixtures/file.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/fixtures/file/sub.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/predefined\_spec.rb  
\* Merlin/Main/Languages/Ruby/Ruby/Builtins/Glob.cs  
\* Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyCommandLine.cs  
\* Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyOptionsParser.cs  
\* Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyUtils.cs

From: Jim D.  
Sent: Monday, April 20, 2009 6:53 PM  
To: Jimmy S.; removed\_email\_address@domain.invalid  
Cc: IronRuby External Code R.  
Subject: RE: Code Review: **FILE** and $PROGRAM\_NAME paths

Comment left on Github:

Can you move the fixtures up a level and combine them? (Put them in  
rubyspec/fixtures instead of rubyspec/command\_line/fixtures and  
rubyspec/language/fixtures)

Also, shouldn’t we move Glob.CanonicalizePath to a more central  
location, then use that central location for both the hosting and the  
Glob implementation? Seems like this couples the hosting API to Glob,  
which doesn’t seem good.  
Other than that it looks good.

JD

From: Jimmy S.  
Sent: Monday, April 20, 2009 3:37 PM  
To: removed\_email\_address@domain.invalid  
Cc: IronRuby External Code R.  
Subject: Code Review: **FILE** and $PROGRAM\_NAME paths

[http://github.com/jschementi/ironruby/commit/3ef1b6ac9718d0c55796c2818da797ea8bab7275](http://github.com/jschementi/ironruby/commit/3ef1b6ac9718d0c55796c2818da797ea8bab7275)

Makes **FILE** and $PROGRAM\_NAME (and $0) have canonicalized paths when  
Ruby is hosted from ir.exe. However, **FILE** is not messed with when  
including a file via require/load. Fixes  
[http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=545](http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=545).

---

<div class="post-metadata">

**Author:** ![jsoho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8baadc/32.png) [@jsoho](https://www.ruby-forum.com/u/jsoho)\
**Post date:** [April 22, 2009, 2:38am UTC](https://www.ruby-forum.com/t/code-review-file-and-program-name-paths/166011/6 "2009-04-22T02:38:14Z")

</div>

Could you remove

public static MutableString/_!_/ CanonicalizePath(MutableString/_!_/  
path) {  
return RubyUtils.CanonicalizePath(path);  
}

from Glob and call RubyUtils directly wherever Glob.CanonicalizePath is  
used?

Other than that looks good.

Tomas

From: Jimmy S.  
Sent: Tuesday, April 21, 2009 5:19 PM  
To: Jim D.; removed\_email\_address@domain.invalid  
Cc: IronRuby External Code R.  
Subject: RE: Code Review: **FILE** and $PROGRAM\_NAME paths

[http://github.com/jschementi/ironruby/commit/57d18b591ba9cba92923864936f359de446e2f97](http://github.com/jschementi/ironruby/commit/57d18b591ba9cba92923864936f359de446e2f97)

Code Review changes

- Moves command\_line/fixtures/file\* and language/fixtures/file\* to  
fixtures/

- Create RubyUtils.CanonicalizePath, to dependency on  
IronRuby.Builtins.Glob from IronRuby.Hosting

Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/command\_line/fixtures/file.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/command\_line/fixtures/file/sub.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/command\_line/program\_name\_spec.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/fixtures/file.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/fixtures/file/sub.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/file\_spec.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/fixtures/file.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/fixtures/file/sub.rb  
\*  
Merlin/External.LCA\_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/predefined\_spec.rb  
\* Merlin/Main/Languages/Ruby/Ruby/Builtins/Glob.cs  
\* Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyCommandLine.cs  
\* Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyOptionsParser.cs  
\* Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyUtils.cs

From: Jim D.  
Sent: Monday, April 20, 2009 6:53 PM  
To: Jimmy S.; removed\_email\_address@domain.invalid  
Cc: IronRuby External Code R.  
Subject: RE: Code Review: **FILE** and $PROGRAM\_NAME paths

Comment left on Github:

Can you move the fixtures up a level and combine them? (Put them in  
rubyspec/fixtures instead of rubyspec/command\_line/fixtures and  
rubyspec/language/fixtures)

Also, shouldn’t we move Glob.CanonicalizePath to a more central  
location, then use that central location for both the hosting and the  
Glob implementation? Seems like this couples the hosting API to Glob,  
which doesn’t seem good.  
Other than that it looks good.

JD

From: Jimmy S.  
Sent: Monday, April 20, 2009 3:37 PM  
To: removed\_email\_address@domain.invalid  
Cc: IronRuby External Code R.  
Subject: Code Review: **FILE** and $PROGRAM\_NAME paths

[http://github.com/jschementi/ironruby/commit/3ef1b6ac9718d0c55796c2818da797ea8bab7275](http://github.com/jschementi/ironruby/commit/3ef1b6ac9718d0c55796c2818da797ea8bab7275)

Makes **FILE** and $PROGRAM\_NAME (and $0) have canonicalized paths when  
Ruby is hosted from ir.exe. However, **FILE** is not messed with when  
including a file via require/load. Fixes  
[http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=545](http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=545).
