Add dryrun capability to autostow.sh
Invoking a dry-run with `autostow.sh -n` will simply print out the directories it would operate on, and those it would ignore and exit. Useful for debugging, not much more.
This commit is contained in:
parent
ea5ffe8bc5
commit
4dfb9767ee
1 changed files with 26 additions and 3 deletions
|
@ -24,6 +24,13 @@ main() {
|
|||
echo "Done removing symlinks ...................................................."
|
||||
exit 0
|
||||
;;
|
||||
-n | --dry-run)
|
||||
have_stow
|
||||
echo "Printing processed directories ............................................"
|
||||
dryrun
|
||||
echo "Done printing directories ................................................."
|
||||
exit 0
|
||||
;;
|
||||
-v | --version)
|
||||
printf "System bootstrap script.\n\n©Marty Oehme\n\nVersion: 0.2\n"
|
||||
;;
|
||||
|
@ -61,6 +68,18 @@ unstow_dirs() {
|
|||
done
|
||||
}
|
||||
|
||||
dryrun() {
|
||||
for d in */; do
|
||||
|
||||
if is_ignored "$d"; then
|
||||
printf "ignoring %s\n" "$d"
|
||||
continue
|
||||
fi
|
||||
|
||||
printf "processing %s\n" "$d"
|
||||
done
|
||||
}
|
||||
|
||||
is_ignored() {
|
||||
IFS=":"
|
||||
for ign in $ignore; do
|
||||
|
@ -84,13 +103,17 @@ usage() {
|
|||
" autostow.sh - Automatically stow your dotfiles." \
|
||||
" Uses GNU stow to set up automatic links to any dotfiles in subdirectories of this directory." \
|
||||
"" \
|
||||
" Usage: stow.sh -dhs" \
|
||||
" Usage: stow.sh -dhsn" \
|
||||
"" \
|
||||
" Options:" \
|
||||
"" \
|
||||
" -h Print out this help." \
|
||||
" -h | --help Print out this help." \
|
||||
"" \
|
||||
" -s Install dotfiles, by symlinking any directory found next to stow.sh using GNU stow." \
|
||||
" -s | --stow Install dotfiles, by symlinking any directory found next to stow.sh using GNU stow." \
|
||||
"" \
|
||||
" -d | --delete Remove dotfiles, by unlinking any directory found next to stow.sh using GNU stow." \
|
||||
"" \
|
||||
" -n | --dry-run Do not invoke any operation but print out directories affected, simulating a dry-run." \
|
||||
"" \
|
||||
" -d Remove dotfiles, by unlinking any directory found next to stow.sh using GNU stow." \
|
||||
"" \
|
||||
|
|
Loading…
Reference in a new issue