From 2a568eeb221079ac69d840246e35882a4d3e0a15 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 12:41:37 +0100 Subject: [PATCH] ifs --- bash/main.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index 5237bd3..029e6f4 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -16,19 +16,20 @@ main_link_bashrc() { main_import_modules() { local file="${1}" if [ -f "${file}" ]; then - local path - local root - path="$(realpath "${file}")" + local ifs module modules path root + path="$(realpath --canonicalize-existing "${file}")" root="$(dirname "${path}")" - local IFS=$'\n' - local modules=($(find "${root}" -type "f" -name "*.sh" | sort)) - local module - for module in "${modules[@]}"; do + modules="$(find "${root}" -type "f" -name "*.sh" | sort)" + ifs="${IFS}" + IFS=" +" + for module in ${modules}; do if [ "${module}" != "${path}" ]; then . "${module}" fi done - log_trace "${modules[@]}" + IFS="${ifs}" + log_trace "${modules}" return 0 else log_fatal "No file: ${file}"