fix(install-script): typo in shebang,feat(install-script): unlink multiple targets

This commit is contained in:
TheK4n 2023-10-12 01:56:17 +03:00
parent 29cb008821
commit c1d4302781

27
install
View File

@ -1,4 +1,4 @@
!/bin/bash #!/bin/bash
set -ueo pipefail set -ueo pipefail
@ -193,12 +193,14 @@ cmd_docker() {
} }
cmd_unlink() { cmd_unlink() {
local target local target targetfile
for target in ${TARGETS["$1"]} for target in "$@"; do
do for targetfile in ${TARGETS["$target"]}
if [ -e "$TARGET_PATH/$target" ]; then do
unlink "$TARGET_PATH/$target" if [ -e "$TARGET_PATH/$targetfile" ]; then
fi unlink "$TARGET_PATH/$targetfile"
fi
done
done done
} }
@ -207,11 +209,11 @@ cmd_no_target() {
} }
cmd_check() { cmd_check() {
local target local targetfile
for target in ${TARGETS["$1"]} for targetfile in ${TARGETS["$1"]}
do do
if [ ! -e "$TARGET_PATH/$target" ]; then if [ ! -e "$TARGET_PATH/$targetfile" ]; then
echo "$target not linked" echo "$targetfile not linked"
fi fi
done done
} }
@ -221,6 +223,7 @@ cmd_list() {
} }
cmd_install() { cmd_install() {
local target
for target in "$@"; do for target in "$@"; do
SANDBOX_PATH="$(mktemp -d)" SANDBOX_PATH="$(mktemp -d)"
case "$target" in case "$target" in
@ -249,7 +252,7 @@ cmd_install() {
cmd_help() { cmd_help() {
echo "Dotfiles installation script: echo "Dotfiles installation script:
Usage: ./install TARGET... Usage: ./install TARGET...
Usage: ./install unlink TARGET Usage: ./install unlink TARGET...
Usage: ./install check TARGET Usage: ./install check TARGET
Usage: ./install list" Usage: ./install list"
} }