commit fd23f96109ed6c60b1b3bfdab1970886997ed645 parent 4a300705c7e655718670d3369c22182a39574cbb Author: Jacob R. Edwards <jacobouno@protonmail.com> Date: Sun, 22 Nov 2020 15:16:57 -0800 Use global shell module directory it does not exist locally Now include() counts SHELL_MODULE_DIR being undefined as an error. The kshrc first checks whether XDG_CONFIG_HOME/shell is a directory and, if it is not, uses /usr/local/share/shell. Diffstat:
| M | modules/ksh/.config/ksh.kshrc | | | 11 | ++++++++--- |
| M | modules/shell/.config/shell/main | | | 2 | +- |
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/modules/ksh/.config/ksh.kshrc b/modules/ksh/.config/ksh.kshrc @@ -1,10 +1,15 @@ -# simple ksh init file +# ksh init file set -Xbh set -o vi -SHELL_MODULE_DIR="$XDG_CONFIG_HOME/shell" -test -f "$SHELL_MODULE_DIR/main" && . "$SHELL_MODULE_DIR/main" +if test -d $XDG_CONFIG_HOME/shell; then + SHELL_MODULE_DIR=$XDG_CONFIG_HOME/shell +else + SHELL_MODULE_DIR=/usr/local/share/shell +fi + +test -f $SHELL_MODULE_DIR/main && . $SHELL_MODULE_DIR/main test -f ~/.profile && . ~/.profile HISTFILE="$HISTBASE/ksh/`date +%Y.%m`" diff --git a/modules/shell/.config/shell/main b/modules/shell/.config/shell/main @@ -4,7 +4,7 @@ __progname=`basename -- $0` # include shell module. include() { - local include="${SHELL_MODULE_DIR:='/usr/local/share/shell'}/$1" + local include="${SHELL_MODULE_DIR:?unset}" test -f "$include" || { printf "%s: include: '%s': File nonexistent.\n" \ $__progname $include;