From 88e4b992d90f2a7283058a1a93c388a9576bad5b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 19 Aug 2016 23:58:25 +1200 Subject: Move OLDPWD setting to POSIX sh dir With an attempt at correct trapping; may still require tweaking --- sh/profile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'sh/profile') diff --git a/sh/profile b/sh/profile index 5dfe0ef3..7fea250b 100644 --- a/sh/profile +++ b/sh/profile @@ -9,6 +9,21 @@ for sh in "$HOME"/.profile.d/*.sh ; do done unset -v sh +# Trap on exit to run ~/.logout if it exists +logout_trap() { + if [ -f "$HOME"/.logout ] ; then + . "$HOME"/.logout + fi + if [ "$1" != EXIT ] ; then + trap - "$1" + kill "-$1" "$$" + fi +} +for sig in EXIT HUP INT TERM ; do + trap "logout_trap $sig" "$sig" +done +unset -v sig + # If ENV is unset after running those scripts and ~/.shrc exists, set it as ENV if [ -z "$ENV" ] && [ -f "$HOME"/.shrc ] ; then ENV=$HOME/.shrc -- cgit v1.2.3