Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Should File::HomeDir honor $ENV{HOME} on Darwin?

by xdg (Monsignor)
on Dec 18, 2008 at 17:21 UTC ( #731325=perlquestion: print w/ replies, xml ) Need Help??
xdg has asked for the wisdom of the Perl Monks concerning the following question:

For all other platforms except Darwin, File::HomeDir->my_home will return $ENV{HOME} if that is set. Fixing it is a trivial patch in Alias' open repository, but I want to be sure it isn't like that for a reason.

So, any reason why my_home shouldn't respect $ENV{HOME} on Darwin?

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Comment on Should File::HomeDir honor $ENV{HOME} on Darwin?
Select or Download Code
Re: Should File::HomeDir honor $ENV{HOME} on Darwin?
by Tanktalus (Canon) on Dec 18, 2008 at 18:27 UTC

    Honestly, I'm not convinced $ENV{HOME} should be used on any platform, other than maybe for test purposes. That said, the method of finding specific directory types on Darwin is awfully convoluted - I'm wondering what changing $ENV{HOME} would do when you're looking for a specific type of directory using Mac::Files::FindFolder...

    Assuming that you apply the same tests with and without $ENV{HOME} set - including nonsensical values, and that said tests are submitted with your patch, I don't see why Adam would say no. Mind you, I've got a larger patch sitting in his queue at the moment from the beginning of November that hasn't made it in, so I'm not sure what RL is doing to him at the moment.

      Honestly, I'm not convinced $ENV{HOME} should be used on any platform...

      If it weren't there already for Unix and Win32 (and MacOS9), I probably wouldn't advocate for it.

      The situation that got me was actually in testing. I'm using a module that uses File::HomeDir to find a config file and I wanted to substitute a new config file in a temporary directory. My quick and dirty approach was just to set $ENV{HOME} to the temporary directory, which turned out to work everywhere except Darwin.

      Instead, I'll probably now mock File::HomeDir and override my_home to return the temporary directory.

      -xdg

      Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://731325]
Approved by kyle
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2014-04-20 09:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls