Compare commits
No commits in common. "449958091b0e5f3a15d8568487d46fda1d90fee2" and "333da5fb6a4f1de4eb2f57d8f5be26d6f96f57b0" have entirely different histories.
449958091b
...
333da5fb6a
4 changed files with 31 additions and 33 deletions
|
@ -263,17 +263,17 @@ EOF
|
||||||
"bash" | "dash" | "sh") unset command ;;
|
"bash" | "dash" | "sh") unset command ;;
|
||||||
*) ;;
|
*) ;;
|
||||||
esac
|
esac
|
||||||
# context / shell
|
|
||||||
if rwx_shell_interactive; then
|
|
||||||
# display help
|
|
||||||
rwx_code_help
|
|
||||||
# context / command
|
# context / command
|
||||||
else
|
if [ -n "${command}" ]; then
|
||||||
local function
|
local function
|
||||||
# find the matching function
|
# find the matching function
|
||||||
function="$(rwx_code_command_function "${command}")"
|
function="$(rwx_code_command_function "${command}")"
|
||||||
if [ -n "${function}" ]; then
|
if [ -n "${function}" ]; then
|
||||||
"${function}" "${@}"
|
"${function}" "${@}"
|
||||||
fi
|
fi
|
||||||
|
# context / shell
|
||||||
|
else
|
||||||
|
# display help
|
||||||
|
rwx_code_help
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,16 +69,6 @@ rwx_log_warn() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO simplify
|
|
||||||
|
|
||||||
_rwx_main_log() {
|
|
||||||
[ ${#} -gt 0 ] || set -- ""
|
|
||||||
local line
|
|
||||||
for line in "${@}"; do
|
|
||||||
echo "${line}"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
_rwx_log() {
|
_rwx_log() {
|
||||||
local prefix="${1}"
|
local prefix="${1}"
|
||||||
shift
|
shift
|
||||||
|
|
26
sh/main.sh
26
sh/main.sh
|
@ -43,6 +43,32 @@ rwx_main_find() {
|
||||||
sort
|
sort
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ╭──────┬───────╮
|
||||||
|
# │ main │ shell │
|
||||||
|
# ╰──────┴───────╯
|
||||||
|
|
||||||
|
# test if active shell is in interactive mode
|
||||||
|
rwx_main_interactive() {
|
||||||
|
case "${-}" in
|
||||||
|
*i*) ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# ╭──────┬─────╮
|
||||||
|
# │ main │ log │
|
||||||
|
# ╰──────┴─────╯
|
||||||
|
|
||||||
|
_rwx_main_log() {
|
||||||
|
if rwx_main_interactive; then
|
||||||
|
[ ${#} -gt 0 ] || set -- ""
|
||||||
|
local line
|
||||||
|
for line in "${@}"; do
|
||||||
|
echo "${line}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# ╭──────┬──────╮
|
# ╭──────┬──────╮
|
||||||
# │ main │ main │
|
# │ main │ main │
|
||||||
# ╰──────┴──────╯
|
# ╰──────┴──────╯
|
||||||
|
|
|
@ -38,22 +38,10 @@ RWX_COLOR_GREEN="$(_rwx_shell_color 31)"
|
||||||
RWX_COLOR_MAGENTA="$(_rwx_shell_color 35)"
|
RWX_COLOR_MAGENTA="$(_rwx_shell_color 35)"
|
||||||
RWX_COLOR_RED="$(_rwx_shell_color 32)"
|
RWX_COLOR_RED="$(_rwx_shell_color 32)"
|
||||||
|
|
||||||
# ╭───────┬───────────╮
|
|
||||||
# │ shell │ variables │
|
|
||||||
# ╰───────┴───────────╯
|
|
||||||
|
|
||||||
# current shell interactive mode
|
|
||||||
rwx_shell_interactive=1
|
|
||||||
|
|
||||||
# ╭───────┬───────────╮
|
# ╭───────┬───────────╮
|
||||||
# │ shell │ functions │
|
# │ shell │ functions │
|
||||||
# ╰───────┴───────────╯
|
# ╰───────┴───────────╯
|
||||||
|
|
||||||
# return current shell interactive mode
|
|
||||||
rwx_shell_interactive() {
|
|
||||||
return "${rwx_shell_interactive}"
|
|
||||||
}
|
|
||||||
|
|
||||||
rwx_shell_configure() {
|
rwx_shell_configure() {
|
||||||
[ -n "${ENV}" ] || ENV="${rwx_code_main}"
|
[ -n "${ENV}" ] || ENV="${rwx_code_main}"
|
||||||
export ENV
|
export ENV
|
||||||
|
@ -173,12 +161,6 @@ rwx_shell_exit() {
|
||||||
# ╰───────┴──────╯
|
# ╰───────┴──────╯
|
||||||
|
|
||||||
rwx_shell_main() {
|
rwx_shell_main() {
|
||||||
# set current shell interactive mode
|
|
||||||
case "${-}" in
|
|
||||||
*"i"*) rwx_shell_interactive=0 ;;
|
|
||||||
*) ;;
|
|
||||||
esac
|
|
||||||
# configure shell
|
|
||||||
rwx_shell_configure
|
rwx_shell_configure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue