summaryrefslogtreecommitdiff
path: root/bin/stow.in
diff options
context:
space:
mode:
authorAdam Spiers <stow@adamspiers.org>2019-06-29 13:04:30 +0100
committerAdam Spiers <stow@adamspiers.org>2019-06-29 13:42:19 +0100
commit9ce10eb3b1cee35906baf1daea8eccc43a4e6623 (patch)
tree0d38948beaf050a38924acbaa431b4598096a7c4 /bin/stow.in
parent4a9121eec90dd7876f44a96489d3357cc9983e78 (diff)
downloadstow-9ce10eb3b1cee35906baf1daea8eccc43a4e6623.tar.gz
Remove dependencies on Hash::Merge and Clone::Choose
stow 2.3.0 added external runtime dependencies on Hash::Merge and Clone::Choose. Historically stow hasn't had runtime dependencies other than Perl itself, which is a useful property if you're managing the installation of Perl using stow; the bootstrapping instructions in stow's manual would need updating to describe how to install these two modules (and any dependencies they have now or in the future) as well. However, Hash::Merge is much more general than stow actually needs, so replace the merge() call with a few lines of equivalent code -- this avoids the external dependencies, and is clearer than the merge() call. Many thanks to Adam Sampson for this patch: https://lists.gnu.org/archive/html/bug-stow/2019-06/msg00001.html
Diffstat (limited to 'bin/stow.in')
-rwxr-xr-xbin/stow.in28
1 files changed, 17 insertions, 11 deletions
diff --git a/bin/stow.in b/bin/stow.in
index 355bbc9..4faa451 100755
--- a/bin/stow.in
+++ b/bin/stow.in
@@ -457,16 +457,12 @@ require 5.006_001;
use POSIX qw(getcwd);
use Getopt::Long qw(GetOptionsFromArray);
+use Scalar::Util qw(reftype);
@USE_LIB_PMDIR@
use Stow;
use Stow::Util qw(parent error);
-# Need to avoid Storable backend, since it can't deal with regexps:
-# https://rt.perl.org/Public/Bug/Display.html?id=50608
-use Clone::Choose qw(:Clone);
-use Hash::Merge qw(merge);
-
my $ProgramName = $0;
$ProgramName =~ s{.*/}{};
@@ -530,17 +526,27 @@ sub process_options {
# Merge .stowrc and command line options.
# Preference is given to cli options.
- # rc options come first in merged arrays.
- # cli options overwrite conflicting rc options.
- Hash::Merge::set_behavior('RIGHT_PRECEDENT');
- my $options = merge($rc_options, $cli_options);
+ my %options = %$rc_options;
+ foreach my $option (keys %$cli_options) {
+ my $rc_value = $rc_options->{$option};
+ my $cli_value = $cli_options->{$option};
+ my $type = reftype($cli_value);
+
+ if (defined $type && $type eq 'ARRAY' && defined $rc_value) {
+ # rc options come first in merged arrays.
+ $options{$option} = [@{$rc_value}, @{$cli_value}];
+ } else {
+ # cli options overwrite conflicting rc options.
+ $options{$option} = $cli_value;
+ }
+ }
# Run checks on the merged options.
- sanitize_path_options($options);
+ sanitize_path_options(\%options);
check_packages($pkgs_to_unstow, $pkgs_to_stow);
# Return merged and processed options.
- return ($options, $pkgs_to_unstow, $pkgs_to_stow);
+ return (\%options, $pkgs_to_unstow, $pkgs_to_stow);
}
#===== SUBROUTINE ===========================================================