File.expand_path with files beginnig with ~ (tilde) on Windoze

Hi,
I have noticed the following Ruby-on-Windoze gotcha:

File.expand_path("~$some_m$word_tmp_file", “.”)

returns just the filename, no expansion is done. I guess this has
something to do with Unix using names starting with “~” for home
directories.
I wonder whether this could/should be fixed.

Cheers,
Grzegorz

“Grzegorz Chrupala” grzegorz@pithekos.net schrieb im Newsbeitrag
news:8b9e2260.0306170157.6b11784d@posting.google.com

Hi,
I have noticed the following Ruby-on-Windoze gotcha:

File.expand_path(“~$some_m$word_tmp_file”, “.”)

returns just the filename, no expansion is done. I guess this has
something to do with Unix using names starting with “~” for home
directories.

Does this work on a Unix platform?

I wonder whether this could/should be fixed.

I guess, it would not be a fix but an additional feature. The “~”
expansion on Unix systems is a shell feature and no Unix built in
functionality.

Cheers

robert

Grzegorz Chrupala wrote:

Hi,
I have noticed the following Ruby-on-Windoze gotcha:

File.expand_path(“~$some_m$word_tmp_file”, “.”)

returns just the filename, no expansion is done. I guess this has
something to do with Unix using names starting with “~” for home
directories.
I wonder whether this could/should be fixed.

What version of Ruby? Here’s what I got:

C:\>irb
irb(main):001:0> File.expand_path("~/temp")
ArgumentError: couldn't find HOME environment -- expanding `~/temp'
        from (irb):1:in `expand_path'
        from (irb):1
irb(main):002:0> VERSION
=> "1.6.8"
···


Chris
http://clabs.org/blogki

returns just the filename, no expansion is done. I guess this has
something to do with Unix using names starting with “~” for home
directories.

That’s a function of various unix shells, not unix itself.

···

Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

What version of Ruby? Here's what I got:

    C:\>irb
    irb(main):001:0> File.expand_path("~/temp")

Can you try it without `/', i.e.

       File.expand_path("~temp")

Guy Decoux

“Robert Klemme” bob.news@gmx.net wrote in message news:bcmv8g$l5psh$1@ID-52924.news.dfncis.de

Does this work on a Unix platform?

It does:

irb(main):004:0> File.expand_path(“~grzegorz”)
=> “/home/grzegorz”

I wonder whether this could/should be fixed.

I guess, it would not be a fix but an additional feature. The “~”

Well, I would simply like file names beginning with “~” to expand on
Windoze as any other file, that is, have the containing directory
prepended, instead of the string being returned as is. This current
behaviour seems broken to me.

expansion on Unix systems is a shell feature and no Unix built in
functionality.

Sorry, I was imprecise.

Cheers,

···


Grzegorz

ts wrote:

Can you try it without `/', i.e.

  File.expand_path("~temp")

Ah, good point:

C:\>irb
irb(main):001:0> File.expand_path("~temp")
=> "~temp"

Chris

Remember that even under unix shells that support “~”, “~temp” and
“~/temp” are 2 different things.

···

— Chris Morris chrismo@clabs.org wrote:

ts wrote:

Can you try it without `/', i.e.

  File.expand_path("~temp")

Ah, good point:

C:\>irb
irb(main):001:0> File.expand_path("~temp")
=> "~temp"

Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!