comments
This commit is contained in:
parent
321070d5cc
commit
b93a6909bb
1 changed files with 12 additions and 0 deletions
12
sh/main.sh
12
sh/main.sh
|
@ -37,6 +37,7 @@ _sh_main_log() {
|
|||
|
||||
# public
|
||||
|
||||
# find directory’s files by extension
|
||||
sh_find_extension() {
|
||||
local extension="${1}"
|
||||
local root="${2}"
|
||||
|
@ -54,16 +55,19 @@ sh_find_extension() {
|
|||
sort
|
||||
}
|
||||
|
||||
# find directory’s sh files
|
||||
sh_find_sh() {
|
||||
sh_find_extension "sh" "${@}"
|
||||
}
|
||||
|
||||
# get functions from file
|
||||
sh_grep_functions() {
|
||||
local file="${1}"
|
||||
grep "()" "${file}" |
|
||||
cut --delimiter "(" --fields 1
|
||||
}
|
||||
|
||||
# output help message
|
||||
sh_help() {
|
||||
sh_log \
|
||||
"sh_… = shell functions" \
|
||||
|
@ -71,6 +75,7 @@ sh_help() {
|
|||
"u__… = user"
|
||||
}
|
||||
|
||||
# test if active shell is in interactive mode
|
||||
sh_shell_interactive() {
|
||||
case "${-}" in
|
||||
*i*) ;;
|
||||
|
@ -106,18 +111,25 @@ sh_source_directory() {
|
|||
|
||||
# main
|
||||
|
||||
# run initial steps
|
||||
sh_main() {
|
||||
# system root
|
||||
if ! sh_source_directory "${SH_ROOT}"; then
|
||||
_sh_main_log "Not a directory: ${SH_ROOT}"
|
||||
return 1
|
||||
fi
|
||||
# user root
|
||||
sh_source_directory "${SH_USER}"
|
||||
# run interactive extras
|
||||
if sh_shell_interactive; then
|
||||
# check
|
||||
sh_log
|
||||
sh_shellcheck "${SH_ROOT}"
|
||||
# help
|
||||
sh_log
|
||||
sh_help
|
||||
fi
|
||||
}
|
||||
|
||||
# run main function
|
||||
sh_main
|
||||
|
|
Loading…
Reference in a new issue