Bug 14560 - resume scripts run in incorrect sort order
Summary: resume scripts run in incorrect sort order
Status: RESOLVED FIXED
Alias: None
Product: pm-utils
Classification: Unclassified
Component: General (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Richard Hughes
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-18 21:20 UTC by Ben Liblit
Modified: 2008-02-19 16:12 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Ben Liblit 2008-02-18 21:20:48 UTC
The scripts in /usr/lib/pm-utils/sleep.d (or some similar location) are supposed to run in reverse order when resuming from suspend.  However, they actually run in the same order.  This causes problems with several order-sensitive scripts in that directory, such as 05led and 95led.

The bug is in function pm_main from the /usr/lib/pm-utils/functions script.  It sets local variable $sort to either "sort" or "sort -r" depending on the desired order.  However, the list of script names is then piped through "sort", rather than "$sort".  Thus, setting $sort to "sort -r" has no affect on the ordering.

Suggested fix: near line 139 of /usr/lib/pm-utils/functions, change this:

                do [ -O "$f" ] && echo ${f##*/} ; done | sort | uniq) ;

to this:

                do [ -O "$f" ] && echo ${f##*/} ; done | eval $sort | uniq) ;

Note that the "eval" is necessary because otherwise the shell will try to find an executable command named "sort -r" rather than running "sort" with "-r" as an argument.
Comment 1 Victor Lowther 2008-02-19 15:08:58 UTC
This is actually happening as a result of a broken merge.  The correct fix is:

diff --git a/pm/functions.in b/pm/functions.in
index 07fa468..f3bdc6c 100644
--- a/pm/functions.in
+++ b/pm/functions.in
@@ -135,8 +135,8 @@ run_hooks()
 "
 	IFS="${nifs}" # tolerate spaces in filenames.
 	[ "$3" = "reverse" ] && sort="sort -r"
-	for base in $(for f in "$syshooks/"*[!~] "$phooks/"*[!~];
-		do [ -O "$f" ] && echo ${f##*/} ; done | sort | uniq) ;
+	for base in $(IFS="${oifs}"; for f in "$syshooks/"*[!~] "$phooks/"*[!~];
+		do [ -O "$f" ] && echo ${f##*/} ; done | $sort | uniq) ;
 	do
 		if [ -f "$syshooks/$base" ]; then
 			hook="$syshooks/$base"

-- 

I will commit this fix to the freedesktop.org upstream.
Comment 2 Victor Lowther 2008-02-19 16:12:44 UTC
Fix pushed to fd.o git repository.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.