From 78eaf1be4acda2cdef17cdff483d8db4b1da23ed Mon Sep 17 00:00:00 2001 From: Christian Storm Date: Mon, 10 Feb 2014 19:01:35 +0100 Subject: [PATCH 1/1] fix load() causing 'exit 1' on missing optional file $PROFILES/postswitch load() should return 1 and hence cause 'exit 1' on a missing config file but it should not implicitly return 1 on a missing optional file $PROFILES/postswitch --- autorandr | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/autorandr b/autorandr index feababd..90d1108 100755 --- a/autorandr +++ b/autorandr @@ -212,19 +212,22 @@ load_cfg_disper() { load() { local PROFILE="$1" local CONF="$PROFILES/$PROFILE/config" - if [ -e "$CONF" ] ; then - [ -x "$PROFILES/preswitch" ] && \ - "$PROFILES/preswitch" "$PROFILE" - [ -x "$PROFILES/$PROFILE/preswitch" ] && \ - "$PROFILES/$PROFILE/preswitch" "$PROFILE" - - echo " -> loading profile $PROFILE" - $LOAD_METHOD "$CONF" - - [ -x "$PROFILES/$PROFILE/postswitch" ] && \ - "$PROFILES/$PROFILE/postswitch" "$PROFILE" - [ -x "$PROFILES/postswitch" ] && \ - "$PROFILES/postswitch" "$PROFILE" + [ -f "$CONF" ] || return 1 + if [ -x "$PROFILES/preswitch" ]; then + "$PROFILES/preswitch" "$PROFILE" + fi + if [ -x "$PROFILES/$PROFILE/preswitch" ]; then + "$PROFILES/$PROFILE/preswitch" "$PROFILE" + fi + + echo " -> loading profile $PROFILE" + $LOAD_METHOD "$CONF" + + if [ -x "$PROFILES/$PROFILE/postswitch" ]; then + "$PROFILES/$PROFILE/postswitch" "$PROFILE" + fi + if [ -x "$PROFILES/postswitch" ]; then + "$PROFILES/postswitch" "$PROFILE" fi } -- 2.39.2