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