Update linkFiles.sh (fix warnings and use flags)

This commit is contained in:
Santiago Lo Coco 2022-02-16 12:34:55 -03:00
parent 4dfcda7827
commit 53e397ded8
1 changed files with 9 additions and 6 deletions

View File

@ -10,11 +10,11 @@ linkFile() {
mv "$2" "${2}.backup"
ln -s "$1" "$2"
else
[ -h "$2" ] && [ "$1" = $(realpath "$2") ] && return
[ -h "$2" ] && [ "$1" = "$(realpath "$2")" ] && return
msg="\nFile already exists: '${2//$HOME\//}', what would you like to do?"
options=(1 "Skip" 2 "Skip all" 3 "Overwrite" 4 "Overwrite all" 5 "Backup" 6 "Backup all")
selectedOption=$(displayDialogBox --menu "$msg" VALUES 0 "${options[@]}" 3>&1 1>&2 2>&3)
selectedOption=$(displayDialogBox --menu "$msg" VALUES "${options[@]}" 3>&1 1>&2 2>&3)
if [ $? -eq 1 ]; then
exit 0
fi
@ -90,12 +90,15 @@ loopThroughFiles() {
files=()
while read -r -d '' srcFile; do
file=$(echo "$srcFile" | awk '{ sub(/.*dotfiles\/other\//, ""); print }')
files+=("$srcFile" "$file" "OFF")
[ $installAll = true ] && files+=("$srcFile" " ") || files+=("$srcFile" "$file" "OFF")
done < <(find -H "$DOTFILES/other" -mindepth 1 -type f -print0)
if [ $installAll = false ]; then
msg="\nSelect the files that you want to install."
files=("$(displayDialogBox --checklist "$msg" VALUES "${files[@]}" 3>&1 1>&2 2>&3)")
files=(${files[@]//$'\n'/ })
[ "${files[0]}" = '' ] && exit
files=("${files[@]//$'\n'/ }")
fi
fi
password=$(displayDialogBox --passwordbox "\nEnter your password." VALUES 3>&1 1>&2 2>&3)