aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdwim6
1 files changed, 4 insertions, 2 deletions
diff --git a/dwim b/dwim
index 91ce5b8..b5fc6b0 100755
--- a/dwim
+++ b/dwim
@@ -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