Project

General

Profile

Actions

Feature #1027

closed

Dir.home

Added by znz (Kazuhiro NISHIYAMA) about 15 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
-
[ruby-core:21454]

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

Actions #1

Updated by nobu (Nobuyoshi Nakada) about 15 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

Actions #2

Updated by rue (Eero Saynatkari) about 15 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

Actions #3

Updated by luislavena (Luis Lavena) about 15 years ago

=begin
On Wed, Jan 21, 2009 at 2:25 PM, Eero Saynatkari 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

Actions #4

Updated by nobu (Nobuyoshi Nakada) about 15 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

Actions #5

Updated by nobu (Nobuyoshi Nakada) about 15 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

Actions #6

Updated by znz (Kazuhiro NISHIYAMA) about 15 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

Actions #7

Updated by ko1 (Koichi Sasada) about 15 years ago

  • Assignee set to matz (Yukihiro Matsumoto)

=begin

=end

Actions #8

Updated by nobu (Nobuyoshi Nakada) about 15 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r21953.
=end

Actions #9

Updated by rogerdpack (Roger Pack) about 15 years ago

=begin
Thanks for doing that Nobu.
-=r
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0