Closed aggrolite closed 9 years ago
Seems like a reasonable solution except it breaks Windows compatibility. I'm not a big fan of adding dependencies, but if File::HomeDir works across *NIX and Win platforms, I'd rather see that.
Also, I'd recommend making the path modifications prior to the debug statement or having a later debug statement show the modification, so that debugging doesn't mislead folks.
Seems like a reasonable solution except it breaks Windows compatibility.
I assumed Windows did not support the ~
shortcut. Am I wrong?
Ah...after some googling Powershell does indeed support ~
. File::HomeDir
then (or an alternative)? Or at the very least, removing the example filepath using ~
in the documentation's synopsis. I personally would like to use the ~
shortcut.
Also, I'd recommend making the path modifications prior to the debug statement or having a later debug statement show the modification, so that debugging doesn't mislead folks.
Noted, thanks. I will make the adjustment.
Apparently glob()
can be used to expand the tilde. I've only tested this on my BSD install. No idea if it works on Windows. Also I have no clue of any corner cases.
Oh, check out File::Path::Expand. This looks like a lighter alternative to File::HomeDir
I've pushed a new commit which uses File::Path::Expand
, which should work on Windows. This module does a search replace, but uses User::pwent
when $ENV{HOME}
does not exist. I don't have a Windows machine to test on, however.
Thoughts?
I'll be happy to add this. Let me do some testing with it first.
Is there any harm in calling File::Path::Expand::expand_filename() on a $file_path without a ~? If not, I would recommend getting rid of the conditional check.
Looking at the source, File::Path::Expand simply does a search/replace on strings beginning with ~
. So the regex check can be removed.
See my latest push. Should be acceptable assuming Windows tests okay.
Running on OSX I provided
~/.reddit
as the session file path, but Perl's open function cannot locate the file. Replacing~
with$ENV{HOME}
before opening the file fixes this issue.I've tested this change on OSX and Debian Linux.
Another solution is using File::HomeDir