From 8982496082a7621f72e19e6653965a236e326f79 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 13 Nov 2024 14:55:20 +0100 Subject: [PATCH] count --- bash/main.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bash/main.sh b/bash/main.sh index 9125fc9..b809dfe 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -16,18 +16,21 @@ main_link_bashrc() { main_import_modules() { local file="${1}" if [ -f "${file}" ]; then - local ifs module modules path root + local count ifs module modules path root path="$(realpath --canonicalize-existing "${file}")" root="$(dirname "${path}")" - echo - echo "${root}" modules="$(find "${root}" -type "f" -name "*.sh" -printf "%P " | sort)" ifs="${IFS}" IFS=" " + count=0 + echo + echo "${root}" for module in ${modules}; do - echo "${module%.sh}" + count=$((count + 1)) + printf "%02d" "${count}" + echo " ${module%.sh}" module="${root}/${module}" if [ "${module}" != "${path}" ]; then . "${module}"