Do more validation on --dir / --target directories (#7)
Previously STOW_DIR=0 would cause the cwd to be used as the STOW_DIR. Make that instead raise an error. Do similar validation on the target directory. Closes #7 - https://github.com/aspiers/stow/pull/7
This commit is contained in:
parent
d0f3e5458f
commit
a111eeb8ae
1 changed files with 6 additions and 1 deletions
|
@ -542,12 +542,17 @@ sub sanitize_path_options {
|
|||
$options->{dir} =~ s/ +\z//;
|
||||
}
|
||||
else {
|
||||
$options->{dir} = $ENV{STOW_DIR} ? $ENV{STOW_DIR} : getcwd();
|
||||
$options->{dir} = length $ENV{STOW_DIR} ? $ENV{STOW_DIR} : getcwd();
|
||||
}
|
||||
|
||||
usage("--dir value '$options->{dir}' is not a valid directory")
|
||||
unless -d $options->{dir};
|
||||
|
||||
if (exists $options->{target}) {
|
||||
$options->{target} =~ s/\A +//;
|
||||
$options->{target} =~ s/ +\z//;
|
||||
usage("--target value '$options->{target}' is not a valid directory")
|
||||
unless -d $options->{target};
|
||||
}
|
||||
else {
|
||||
$options->{target} = parent($options->{dir}) || '.';
|
||||
|
|
Loading…
Reference in a new issue