]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
fix load() causing 'exit 1' on missing optional file $PROFILES/postswitch
authorChristian Storm <christian.storm@tngtech.com>
Mon, 10 Feb 2014 18:01:35 +0000 (19:01 +0100)
committerChristian Storm <christian.storm@tngtech.com>
Mon, 10 Feb 2014 18:01:35 +0000 (19:01 +0100)
    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

index feababdbb03e1f3bd5fa9f8df999cc7b18c25a39..90d110831ba0a9efe1c3f2aeefdeb3aa1ae799e0 100755 (executable)
--- 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
 }