use bash parameter-expansion

This commit is contained in:
Jakobus Schürz 2020-03-12 20:59:57 +01:00
parent 2d6a4a5d05
commit 945b2f8348
2 changed files with 5 additions and 4 deletions

View file

@ -11,8 +11,9 @@ if [[ $- = *i* ]] ; then
#echo "interactive shell" >&2
# define variables
[ -z "${MYSHELLCONFIG_ROOT_TMOUT+x}" ] && MYSHELLCONFIG_ROOT_TMOUT=500
[ -z "${MYSHELLCONFIG_USER_TMOUT+x}" ] && MYSHELLCONFIG_USER_TMOUT=0
# default timeouts definted in myshellconfig_load_default
#[ -z "${MYSHELLCONFIG_ROOT_TMOUT+x}" ] && MYSHELLCONFIG_ROOT_TMOUT=500
#[ -z "${MYSHELLCONFIG_USER_TMOUT+x}" ] && MYSHELLCONFIG_USER_TMOUT=0
[ -z "${USERNAME+x}" ] && USERNAME="$USER"
[ -z "${USEREMAIL+x}" ] && USEREMAIL="$USER@$(domainname -f)"
[ -z "${FULLNAME+x}" ] && FULLNAME="$(getent passwd $USER | cut -d ":" -f 5 | cut -d ',' -f 1)"

View file

@ -7,10 +7,10 @@ case $(tty) in
#[ $( id -u ) -gt 0 ] && TMOUT=${MYSHELLCONFIG_USER_TMOUT}
case $(id u) in
0)
TMOUT=${MYSHELLCONFIG_ROOT_TMOUT}
TMOUT=${MYSHELLCONFIG_ROOT_TMOUT:-500}
;;
*)
TMOUT=${MYSHELLCONFIG_USER_TMOUT}
TMOUT=${MYSHELLCONFIG_USER_TMOUT:-0}
;;
esac
echo "Run in TTY -> set autologout \$TMOUT=$TMOUT" >&2