From 0e8cab41f6c03824e46b3015b440f0eea213c84c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Nov 2024 18:39:25 +0100 Subject: [PATCH] shellcheck --- sh/main.sh | 28 ++++++---------------------- sh/shellcheck.sh | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 22 deletions(-) create mode 100644 sh/shellcheck.sh diff --git a/sh/main.sh b/sh/main.sh index 2a351c9..83f0705 100644 --- a/sh/main.sh +++ b/sh/main.sh @@ -38,27 +38,7 @@ _sh_main_log() { esac } -# - -sh_source_check() { - local root="${1}" - local file module modules - file="$(mktemp)" - modules="$(sh_source_find "${root}")" - _sh_ifs_new - for module in ${modules}; do - echo ". \"${root}/${module}\"" >>"${file}" - done - _sh_ifs_pop - shellcheck \ - --check-sourced \ - --enable "all" \ - --exclude "3043" \ - --external-sources \ - --shell "dash" \ - "${file}" - rm "${file}" -} +# sort sh_source_find() { local root="${1}" @@ -120,6 +100,8 @@ main_source_file() { fi } +# public + sh_help() { sh_log \ "sh_… = shell functions" \ @@ -131,9 +113,11 @@ sh_main() { main_source_file "${ENV}" main_source_directory "${SH_USER}" sh_log - sh_source_check "$(dirname "${ENV}")" + sh_shellcheck "$(dirname "${ENV}")" sh_log sh_help } +# main + sh_main diff --git a/sh/shellcheck.sh b/sh/shellcheck.sh new file mode 100644 index 0000000..d5ccb53 --- /dev/null +++ b/sh/shellcheck.sh @@ -0,0 +1,19 @@ +sh_shellcheck() { + local root="${1}" + local file module modules + file="$(mktemp)" + modules="$(sh_source_find "${root}")" + _sh_ifs_new + for module in ${modules}; do + echo ". \"${root}/${module}\"" >>"${file}" + done + _sh_ifs_pop + shellcheck \ + --check-sourced \ + --enable "all" \ + --exclude "3043" \ + --external-sources \ + --shell "dash" \ + "${file}" + rm "${file}" +}