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}" +}