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 ...................................................."
|
echo "Done removing symlinks ...................................................."
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
-n | --dry-run)
|
||||||
|
have_stow
|
||||||
|
echo "Printing processed directories ............................................"
|
||||||
|
dryrun
|
||||||
|
echo "Done printing directories ................................................."
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
-v | --version)
|
-v | --version)
|
||||||
printf "System bootstrap script.\n\n©Marty Oehme\n\nVersion: 0.2\n"
|
printf "System bootstrap script.\n\n©Marty Oehme\n\nVersion: 0.2\n"
|
||||||
;;
|
;;
|
||||||
|
@ -61,6 +68,18 @@ unstow_dirs() {
|
||||||
done
|
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() {
|
is_ignored() {
|
||||||
IFS=":"
|
IFS=":"
|
||||||
for ign in $ignore; do
|
for ign in $ignore; do
|
||||||
|
@ -84,13 +103,17 @@ usage() {
|
||||||
" autostow.sh - Automatically stow your dotfiles." \
|
" autostow.sh - Automatically stow your dotfiles." \
|
||||||
" Uses GNU stow to set up automatic links to any dotfiles in subdirectories of this directory." \
|
" 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:" \
|
" 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." \
|
" -d Remove dotfiles, by unlinking any directory found next to stow.sh using GNU stow." \
|
||||||
"" \
|
"" \
|
||||||
|
|
Loading…
Reference in a new issue