summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVictor Lowther <victor.lowther@gmail.com>2008-04-30 19:15:31 -0500
committerVictor Lowther <victor.lowther@gmail.com>2008-04-30 19:15:31 -0500
commit39b5eb3eb9a7353c5dacc91b672afae3ce9c97de (patch)
tree82f9d806d5cdb43b04e77f89450a6e59de61ffd2 /src
parentd98360b945cd44701a925192f36d7ef681a92823 (diff)
Normalize error checking introduced by a068f3fbc7c522.
'if [ command_exists "do_$METHOD" ]' always returns true -- [ is a command, not shell syntax.
Diffstat (limited to 'src')
-rw-r--r--src/pm-action.in45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/pm-action.in b/src/pm-action.in
index bc6715e..46410e2 100644
--- a/src/pm-action.in
+++ b/src/pm-action.in
@@ -55,12 +55,20 @@ done
METHOD="$(echo ${0##*pm-} |tr - _)"
-"check_$METHOD" || { echo "System does not support $METHOD sleep."; exit 1; }
+command_exists "check_$METHOD" && command_exists "do_$METHOD" || {
+ log "pm-utils does not know how to $1 on this system."
+ exit 1
+}
+
+"check_$METHOD" || {
+ log "This system does not support $METHOD as a sleep method."
+ exit 1
+}
case "$METHOD" in
suspend*) ACTION=suspend; REVERSE=resume ;;
hibernate) ACTION=hibernate; REVERSE=thaw ;;
- *) echo "Don't know how to ${METHOD}."
+ *) echo "Cannot happen. Please file a bug against pm-utils."
exit 1 ;;
esac
@@ -72,24 +80,19 @@ load_hook_parameters
# Make sure we are not inhibited before we start.
rm -f "${INHIBIT}"
-if [ command_exists "do_$METHOD" ]; then
- # run the sleep hooks
- log "$(date): Running hooks for $ACTION."
- run_hooks sleep "$ACTION"
- # Sleep only if we know how and if a hook did not inhibit us.
- if [ ! -e "$INHIBIT" ]; then
- log "$(date): performing $METHOD"
- sync
- "do_$METHOD"
- log "$(date): Awake."
- else
- log "$(date): Inhibit found, will not perform $METHOD"
- fi
- log "$(date): Running hooks for $REVERSE"
- # run the sleep hooks in reverse with the wakeup action
- run_hooks sleep "$REVERSE" reverse
- log "$(date): Finished."
+# run the sleep hooks
+log "$(date): Running hooks for $ACTION."
+run_hooks sleep "$ACTION"
+# Sleep only if we know how and if a hook did not inhibit us.
+if [ ! -e "$INHIBIT" ]; then
+ log "$(date): performing $METHOD"
+ sync
+ "do_$METHOD"
+ log "$(date): Awake."
else
- log "$(date): Missing module to perform $METHOD - abort."
- exit 1
+ log "$(date): Inhibit found, will not perform $METHOD"
fi
+log "$(date): Running hooks for $REVERSE"
+# run the sleep hooks in reverse with the wakeup action
+run_hooks sleep "$REVERSE" reverse
+log "$(date): Finished."