From dcde6ddbc9e7722e3edcf7e6b694e7dfbde206a1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 17 Nov 2024 18:11:25 +0100 Subject: [PATCH] commands --- shell/main.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/shell/main.sh b/shell/main.sh index 85888e7..e41bdf9 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -1,9 +1,15 @@ [ -n "${ENV}" ] || export ENV="/etc/shell/main.sh" +main_commands() { + local file="${1}" + grep "{\$" "${file}" | + cut --delimiter "(" --fields 1 +} + main_source_directory() { local path="${1}" if [ -d "${path}" ]; then - local count ifs module modules + local cmd count ifs module modules modules="$(find "${path}" \ -type "f" \ -name "*.sh" \ @@ -22,9 +28,14 @@ main_source_directory() { module="${path}/${module}" if [ "${module}" != "${ENV}" ]; then . "${module}" + cmd="$(main_commands "${module}")" + [ -n "${cmd}" ] && CMD="${CMD} +${cmd}" fi done IFS="${ifs}" + log_info + log_info "${CMD}" else echo "Not a directory: ${path}" return 1