diff --git a/bin/stow.in b/bin/stow.in index 024b152..c4654d0 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -460,6 +460,7 @@ require 5.006_001; use POSIX qw(getcwd); use Getopt::Long qw(GetOptionsFromArray); use Scalar::Util qw(reftype); +use Text::ParseWords qw(shellwords); @USE_LIB_PMDIR@ use Stow; @@ -683,7 +684,7 @@ sub get_config_file_options { or die "Could not open $file for reading\n"; while (my $line = <$FILE>){ chomp $line; - push @defaults, split " ", $line; + push @defaults, shellwords($line); } close $FILE or die "Could not close open file: $file\n"; } diff --git a/t/rc_options.t b/t/rc_options.t index cbbbee2..bc36e78 100755 --- a/t/rc_options.t +++ b/t/rc_options.t @@ -22,7 +22,7 @@ use strict; use warnings; -use Test::More tests => 34; +use Test::More tests => 35; use testutil; @@ -119,6 +119,19 @@ is($options->{target}, "$ABS_TEST_DIR/target" is($options->{dir}, "$ABS_TEST_DIR/stow" => "-d from \$HOME/.stowrc"); +# +# Test ~/.stowrc file with with options with paths containing spaces. +# +local @ARGV = ('dummy'); +make_file($HOME_RC_FILE, <{dir}, "$ABS_TEST_DIR/stow directory", + => "-d from \$HOME/.stowrc with spaces"); + # # Test that some but not all options ~/.stowrc file are overridden by # .stowrc in cwd. @@ -229,11 +242,11 @@ is($options->{dir}, "$ABS_TEST_DIR/stow", "apply environment expansion on \$HOME/.stowrc --dir"); is($options->{target}, "$ABS_TEST_DIR/stow", "apply environment expansion on \$HOME/.stowrc --target"); -is_deeply($options->{ignore}, [qr(\$HOME\z)], +is($options->{ignore}->[0], '(?^:$HOME\z)', "environment expansion not applied on --ignore"); -is_deeply($options->{defer}, [qr(\A\$HOME)], +is($options->{defer}->[0], '(?^:\A$HOME)', "environment expansion not applied on --defer"); -is_deeply($options->{override}, [qr(\A\$HOME)], +is($options->{override}->[0], '(?^:\A$HOME)', "environment expansion not applied on --override"); # @@ -263,4 +276,3 @@ is_deeply($options->{override}, [qr(\A~/stow)], # unlink $HOME_RC_FILE or die "Unable to clean up $HOME_RC_FILE.\n"; remove_dir($ABS_TEST_DIR); - diff --git a/t/testutil.pm b/t/testutil.pm index 2b4e097..9fb9862 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -56,7 +56,7 @@ sub init_test_dirs { # Create a run_from/ subdirectory for tests which want to run # from a separate directory outside the Stow directory or # target directory. - for my $dir ("target", "stow", "run_from") { + for my $dir ("target", "stow", "run_from", "stow directory") { my $path = "$test_dir/$dir"; -d $path and remove_tree($path); make_path($path);