Feature #1027
closedDir.home
Description
=begin
I request Dir.home again.
previous request was [ruby-dev:31957]¶
Portable way of getting home directory is complex see [ruby-core:12347].
I think a simplest getting home directory is
Dir.chdir { Dir.pwd }
now.
But this is not thread-safe and changes directory needlessness.
=end
Updated by nobu (Nobuyoshi Nakada) about 16 years ago
=begin
Hi,
At Tue, 20 Jan 2009 18:00:00 +0900,
Kazuhiro NISHIYAMA wrote in [ruby-core:21454]:
Portable way of getting home directory is complex see [ruby-core:12347].
I think a simplest getting home directory is
Dir.chdir { Dir.pwd }
now.
But this is not thread-safe and changes directory needlessness.
File.expand_path("~") works.
--
Nobu Nakada
=end
Updated by rue (Eero Saynatkari) about 16 years ago
=begin
Excerpts from Nobuyoshi Nakada's message of Wed Jan 21 05:19:23 +0200 2009:
Hi,
At Tue, 20 Jan 2009 18:00:00 +0900,
Kazuhiro NISHIYAMA wrote in [ruby-core:21454]:Portable way of getting home directory is complex see [ruby-core:12347].
I think a simplest getting home directory is
Dir.chdir { Dir.pwd }
now.
But this is not thread-safe and changes directory needlessness.File.expand_path("~") works.
A Dir.home might be more idiomatic considering Windows et al.
(And, of course, File.expand_path ""
does not expand to the
home directory in 1.8.6 at least, which may or may not be
expected.)
--
Magic is insufficiently advanced technology.
=end
Updated by luislavena (Luis Lavena) about 16 years ago
=begin
On Wed, Jan 21, 2009 at 2:25 PM, Eero Saynatkari ruby-ml@kittensoft.org wrote:
Excerpts from Nobuyoshi Nakada's message of Wed Jan 21 05:19:23 +0200 2009:
Hi,
At Tue, 20 Jan 2009 18:00:00 +0900,
Kazuhiro NISHIYAMA wrote in [ruby-core:21454]:Portable way of getting home directory is complex see [ruby-core:12347].
I think a simplest getting home directory is
Dir.chdir { Dir.pwd }
now.
But this is not thread-safe and changes directory needlessness.File.expand_path("~") works.
A Dir.home might be more idiomatic considering Windows et al.
(And, of course,File.expand_path ""
does not expand to the
home directory in 1.8.6 at least, which may or may not be
expected.)
The changes File.expand_path("~") has not been backported to 1.8.6,
and I believe they will not be.
For that purpose, I always set HOME=%HOMEDRIVE%%HOMEPATH%
Agree on the idiomatic / Ruby style for Dir.home, that will be a nice addition.
--
Luis Lavena
AREA 17
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry
=end
Updated by nobu (Nobuyoshi Nakada) about 16 years ago
=begin
Hi,
At Thu, 22 Jan 2009 01:30:00 +0900,
Luis Lavena wrote in [ruby-core:21491]:
The changes File.expand_path("~") has not been backported to 1.8.6,
and I believe they will not be.
What change? Using %HOMEDRIVE%%HOMEPATH%, %USERPROFILE% or the
personal folder patch has been backported at p127, in Jun 2008.
--
Nobu Nakada
=end
Updated by nobu (Nobuyoshi Nakada) about 16 years ago
=begin
Hi,
At Thu, 22 Jan 2009 01:25:05 +0900,
Eero Saynatkari wrote in [ruby-core:21490]:
(And, of course,
File.expand_path ""
does not expand to the
home directory in 1.8.6 at least, which may or may not be
expected.)
It is not expected definitely. It should be the current
working directory.
--
Nobu Nakada
=end
Updated by znz (Kazuhiro NISHIYAMA) about 16 years ago
=begin
At Thu, 22 Jan 2009 23:26:40 +0900,
C.E. Thornton wrote:
Dir.chdir(File.expand_path("~")) works on linux/unix
systems. Does that concept of a "home" Directory translate
to other OS's?
If Dir.chdir without arguments works,
Dir.home can return the directory.
Otherwise Dir.home will raise exception or return nil,
I think.
=end
Updated by ko1 (Koichi Sasada) about 16 years ago
- Assignee set to matz (Yukihiro Matsumoto)
=begin
=end
Updated by nobu (Nobuyoshi Nakada) about 16 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
Applied in changeset r21953.
=end
Updated by rogerdpack (Roger Pack) about 16 years ago
=begin
Thanks for doing that Nobu.
-=r
=end