blob: fba2beba6bc9f24a93c3de0452e0e22c1c280129 [file] [log] [blame]
From 27be03f0dbacd4b078ed18ee43ad3c710b569260 Mon Sep 17 00:00:00 2001
From: Daniel Kurtz <djkurtz@chromium.org>
Date: Wed, 11 May 2011 19:09:52 +0800
Subject: [PATCH] Skip failed globs when finding module scripts
Globs return the glob expression itself if there are no valid expansions (Unless using the bash-specific "setopt -u nullglob").
Fix this by detecting and ignoring SCRIPT when it is not a file.
BUG=chromium-os:15187
TEST=(0) Enable laptop_mode verbose output (set VERBOSE_OUTPUT=1 in /etc/laptop-mode/laptop-mode.conf)
(1) sudo /usr/sbin/laptop_mode auto force
The following should not be present at end of output:
Module /usr/local/lib/laptop-mode-tools/modules/* is not executable or is to be skipped.
Module /usr/local/share/laptop-mode-tools/modules/* is not executable or is to be skipped.
Module /etc/laptop-mode/modules/* is not executable or is to be skipped.
---
usr/sbin/laptop_mode | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/usr/sbin/laptop_mode b/usr/sbin/laptop_mode
index 7877f80..71a5cbe 100755
--- laptop-mode-tools-1.59/usr/sbin/laptop_mode
+++ laptop-mode-tools-1.59/usr/sbin/laptop_mode
@@ -1038,6 +1038,9 @@ lmt_main_function ()
# Note that the /usr/local/lib path is deprecated.
export FORCE STATE ON_AC ACTIVATE ACTIVATE_WITH_POSSIBLE_DATA_LOSS KLEVEL KMINOR WAS_ACTIVE LM_VERBOSE DEVICES
for SCRIPT in /usr/share/laptop-mode-tools/modules/* /usr/local/lib/laptop-mode-tools/modules/* /usr/local/share/laptop-mode-tools/modules/* /etc/laptop-mode/modules/* ; do
+ # Skip failed globs
+ [ -f "$SCRIPT" ] || continue
+
if [ -z "$MODULES" ] ; then
# If a module list has not been provided, execute all modules
EXECUTE_SCRIPT=1
--
1.7.3.1