From 1f66b9dc577bb29e979275261ac81246a698fddb Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Fri, 31 Dec 2021 12:37:20 -0300 Subject: [PATCH] Add runDetachedScript() --- scripts/linkFiles.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/linkFiles.sh b/scripts/linkFiles.sh index 33742a7..d85f44e 100755 --- a/scripts/linkFiles.sh +++ b/scripts/linkFiles.sh @@ -85,18 +85,26 @@ loopThroughFiles() { displayDialogBox --yesno "There are 'other' files, would you like to install them?\n\n$filesOutput" || return fi + sudo bash -c "$(declare -f runDetachedScript); $(declare -f linkFile); "runDetachedScript"" +} + +runDetachedScript() { + source scripts/common.sh + + DOTFILES_OTHER=$(pwd -P)/dotfiles/other + for srcFile in $(find -H "$DOTFILES_OTHER"); do if [[ -d "$srcFile" ]]; then var=$(echo "$srcFile" | awk '{ sub(/.*CocoRice\/dotfiles\/other\//, ""); print }') if [[ ! -d "/$var" ]]; then - sudo mkdir -p "/$var" + mkdir -p "/$var" fi fi if [[ -f "$srcFile" ]]; then var=$(echo "$srcFile" | awk '{ sub(/.*CocoRice\/dotfiles\/other\//, ""); print }') - sudo bash -c "$(declare -f linkFile); "linkFile" "$srcFile" "/$var"" + linkFile "$srcFile" "/$var" fi done }