From d0f3e5458fd9f93bff68cb2047ad531c7e0e9375 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 11 Nov 2015 11:22:05 +0000 Subject: [PATCH] Correctly handle empty STOW_DIR (#5, #6) In shell, a variable is often considered unset even if it is set to the empty string. In other words, STOW_DIR= stow [args] is an idiomatic alternative to writing: unset STOW_DIR stow [args] and it also has the advantage of temporarily "unsetting" STOW_DIR for a single command. Therefore we should treat STOW_DIR being set to the empty string as equivalent to it not being set at all. Thanks to Cuong Manh Le for highlighting this issue! Fixes #6 - https://github.com/aspiers/stow/issues/6 Closes #5 - https://github.com/aspiers/stow/pull/5 --- THANKS | 1 + bin/stow.in | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/THANKS b/THANKS index 191e0ba..bd3b5a9 100644 --- a/THANKS +++ b/THANKS @@ -23,3 +23,4 @@ Christopher Hoobin Adam Spiers Stefano Lattarini Adam Sampson +Cuong Manh Le diff --git a/bin/stow.in b/bin/stow.in index 5263fe8..c437f29 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -542,7 +542,7 @@ sub sanitize_path_options { $options->{dir} =~ s/ +\z//; } else { - $options->{dir} = exists $ENV{STOW_DIR} ? $ENV{STOW_DIR} : getcwd(); + $options->{dir} = $ENV{STOW_DIR} ? $ENV{STOW_DIR} : getcwd(); } if (exists $options->{target}) {