diff options
author | John Ankarström <john@ankarstrom.se> | 2021-06-15 08:10:01 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-06-15 08:10:01 +0200 |
commit | 6371fdd6eaf706a51369b096071ac2e5969f8f48 (patch) | |
tree | 392d4f0d9ae9c56eda244a3acfbc74b236abbf09 | |
parent | 0590c64260739c0736967b69654f89bee98ed5df (diff) | |
download | dwim-6371fdd6eaf706a51369b096071ac2e5969f8f48.tar.gz |
Improve 'path' subroutine
-rwxr-xr-x | dwim | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -137,8 +137,10 @@ sub path { my $n = shift; $n =~ s,^~([^/]+),/home/$1,; $n =~ s,^~,/home/$ENV{USER},; - return $n if $n =~ /^\// or $n =~ /^~/; - return dir . "/$n"; + goto done if $n =~ /^\// or $n =~ /^~/; + $n = dir . "/$n"; +done: chdir dirname($n); + return $n; } # take K => V and return environment variable K if defined, otherwise V |