diff --git a/bin/stow.in b/bin/stow.in index 4faa451..c3c2a7b 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -206,6 +206,12 @@ changing. Disable folding of newly stowed directories when stowing, and refolding of newly foldable directories when unstowing. +=item --absolute + +=item -a + +Use absolute paths + =item --ignore=REGEX Ignore files ending in this Perl regex. @@ -574,7 +580,7 @@ sub parse_options { \%options, 'verbose|v:+', 'help|h', 'simulate|n|no', 'version|V', 'compat|p', 'dir|d=s', 'target|t=s', - 'adopt', 'no-folding', 'dotfiles', + 'adopt', 'no-folding', 'dotfiles', 'absolute|a', # clean and pre-compile any regex's at parse time 'ignore=s' => @@ -814,6 +820,11 @@ OPTIONS: -D, --delete Unstow the package names that follow this option -R, --restow Restow (like stow -D followed by stow -S) + -a, --absolute Use absolute paths + --dotfiles Convert filenames starting with `dot-' to `.' + + --no-folding Disable folding of newly stowed directories when stowing, + and refolding of newly foldable directories when unstowing. --ignore=REGEX Ignore files ending in this Perl regex --defer=REGEX Don't stow files beginning with this Perl regex if the file is already stowed to another package diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 77f67b3..3a36f45 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -78,6 +78,7 @@ our %DEFAULT_OPTIONS = ( dotfiles => 0, adopt => 0, 'no-folding' => 0, + absolute => 0, ignore => [], override => [], defer => [], @@ -119,6 +120,8 @@ See the documentation for the F CLI front-end for information on these. =item * no-folding +=item * absolute + =item * ignore =item * override @@ -202,10 +205,15 @@ sub set_stow_dir { my $stow_dir = canon_path($self->{dir}); my $target = canon_path($self->{target}); - $self->{stow_path} = File::Spec->abs2rel($stow_dir, $target); + $self->{stow_path} = $self->{absolute} ? $stow_dir : + File::Spec->abs2rel($stow_dir, $target); debug(2, "stow dir is $stow_dir"); - debug(2, "stow dir path relative to target $target is $self->{stow_path}"); + if (!$self->{absolute}) { + debug(2, "stow dir path relative to target $target is $self->{stow_path}"); + } else { + debug(2, "stow dir path for target $target is $self->{stow_path}"); + } } sub init_state { @@ -437,7 +445,7 @@ sub stow_node { debug(4, " => $source"); # Don't try to stow absolute symlinks (they can't be unstowed) - if (-l $source) { + if ((not $self->{absolute}) && -l $source) { my $second_source = $self->read_a_link($source); if ($second_source =~ m{\A/}) { $self->conflict( @@ -450,6 +458,10 @@ sub stow_node { } } + if ($self->{absolute}) { + debug(3, "Absolute symlinks cannot be unstowed, proceeding due to command-line option"); + } + # Does the target already exist? if ($self->is_a_link($target)) { # Where is the link pointing? @@ -815,7 +827,7 @@ sub unstow_node { error("Could not read link: $target"); } - if ($existing_source =~ m{\A/}) { + if (not $self->{absolute} and $existing_source =~ m{\A/}) { warn "Ignoring an absolute symlink: $target => $existing_source\n"; return; # XXX # }