From: Christian Storm Date: Mon, 10 Feb 2014 18:01:35 +0000 (+0100) Subject: fix load() causing 'exit 1' on missing optional file $PROFILES/postswitch X-Git-Tag: 1.0~139^2 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=78eaf1be4acda2cdef17cdff483d8db4b1da23ed;hp=d815adbcd3e50a830f6133305221ef3fc249be08;p=deb_pkgs%2Fautorandr.git 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 --- 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 }