fsh/kor/bash.src
Tessa L 572d4b8f98 Installation/loading order refactor.
Use of shimMe, shimState, and unShimMe confirmed working.
Shuffled a bit of stuff from several sources, trying to categorize, localize, and group related chunks together.
Bash allows you to do things almost any way, but it's the 'almost' that seems to cause the most problems.
2020-11-23 13:15:44 -08:00

62 lines
1.6 KiB
Plaintext

#
# @todo - add hashbang
#
### Bash environment setup stuffs ###
# If executed, setup boilerplate
if [ "$0" == "$BASH_SOURCE" ];then
## bash debugging boilerplate
#
# this chunk sets up how early scripts fail (we prefer earlier)
# and is supposed to serve as the template for other `fsh` scripts,
# acting as both documentation and implementation.
#
# clearly, it is several versions behind the ideal, though the bones are good.
#
# @todo - integrate with commandRegistry['logLevel'] ?
# @todo - document the (rest of the) `set` options
#
if test "$BASH" = "" || "$BASH" -uc "a=();true \"\${a[@]}\"" 2>/dev/null; then
# @doc:set
# to enable per-line display, use -x in addition
# eg: set -x
# magic bits
set -Eeuo pipefail
else
echo "this tool requires bash v4.4+:"
echo
bash --version
echo
echo "(and your version is insufficient :-/ )"
exit 13
fi
## end boilerplate ##
# executed --^
# (eg running `${fDir}/kor/bash.src` in the shell, or in a script)
else
# (sourced usage, eg `. ${fDir}/kor/bash.src` )
# v-- sourced
# (immediate history append, functionally forever scrollback)
# disable size-based history file trimming.
export HISTSIZE=
export HISTFILESIZE= # <-- same as above, just a different variable.
# Share commands with sibling shells
shopt -s histappend # <-- append to the history file sooner than later.
# @todo - recreate utility of staging the devlog and changes to the task list.
# --> file/folder modification triggers?
# export PROMPT_COMMAND="history -a;$PROMPT_COMMAND ksave"
#
# until then, just append the history here.
export PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
fi