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

23
install
View File

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