On Monday 24 December 2007 00:03:20 Richard Hughes wrote:

> I've applied all these, thanks.

Thank you. Here are three more patches, one makes pm-action display the 
filename it was invoked with in the help screen. The next adds a missing 
uniq. Otherwise some files in sleep.d or power.d may run twice. The last one 
sets nullglob, to make the results of filename expansion empty, in case the 
pattern does not match.

The last two issues are explained in:
https://bugzilla.redhat.com/show_bug.cgi?id=302401

Regards and Merry Christmas,
Till
Red Hat Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=302401
(Issue 2 in the bug report)

Without the uniq files in the sleep.d or power.d directory may run twice.
Also this patch removes a uneccessary "-e" test in the if statements, the
"-x" test already includes a "-e" test.

Also this patch adds a modeline for vim no to expand tabs, because tabs are
used in the files for indentation.

Index: pm/functions
===================================================================
RCS file: /cvs/pm-utils/pm-utils/pm/functions,v
retrieving revision 1.47
diff -u -r1.47 functions
--- pm/functions	23 Dec 2007 23:01:46 -0000	1.47
+++ pm/functions	24 Dec 2007 12:24:25 -0000
@@ -1,4 +1,5 @@
 #!/bin/bash
+# vim:noexpandtab
 
 export PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/lib/pm-utils/bin
 
@@ -58,12 +59,10 @@
 find_sleepd_files()
 {
 	flist="/etc/pm/sleep.d/*[^~] /usr/lib/pm-utils/sleep.d/*[^~]"
-	bases=$(for file in $flist ; do echo $(basename $file) ; done | sort -n)
+	bases=$(for file in $flist ; do echo $(basename $file) ; done | sort -n | uniq)
 	for base in $bases ; do
-		if [ -e "/etc/pm/sleep.d/$base" ]; then
-			if [ -x "/etc/pm/sleep.d/$base" ]; then
-				echo /etc/pm/sleep.d/$base
-			fi
+		if [ -x "/etc/pm/sleep.d/$base" ]; then
+			echo /etc/pm/sleep.d/$base
 		elif [ -x "/usr/lib/pm-utils/sleep.d/$base" ]; then
 			echo /usr/lib/pm-utils/sleep.d/$base
 		fi
Index: src/pm-powersave
===================================================================
RCS file: /cvs/pm-utils/pm-utils/src/pm-powersave,v
retrieving revision 1.7
diff -u -r1.7 pm-powersave
--- src/pm-powersave	6 Mar 2007 19:08:06 -0000	1.7
+++ src/pm-powersave	24 Dec 2007 12:24:25 -0000
@@ -1,5 +1,5 @@
 #!/bin/bash
-#
+# vim:noexpandtab
 # Simple powersave script
 #
 # Copyright 2006 Red Hat, Inc.
@@ -27,12 +27,10 @@
 find_powerd_files()
 {
 	flist="/etc/pm/power.d/*[^~] /usr/lib/pm-utils/power.d/*[^~]"
-	bases=$(for file in $flist ; do echo $(basename $file) ; done | sort -n)
+	bases=$(for file in $flist ; do echo $(basename $file) ; done | sort -n | uniq)
 	for base in $bases ; do
-		if [ -e "/etc/pm/power.d/$base" ]; then
-			if [ -x "/etc/pm/power.d/$base" ]; then
-				echo /etc/pm/power.d/$base
-			fi
+		if [ -x "/etc/pm/power.d/$base" ]; then
+			echo /etc/pm/power.d/$base
 		elif [ -x "/usr/lib/pm-utils/power.d/$base" ]; then
 			echo /usr/lib/pm-utils/power.d/$base
 		fi
This patch makes pm-action show the filename in help, that was used
to invoke it, e.g. pm-suspend

Index: src/pm-action
===================================================================
RCS file: /cvs/pm-utils/pm-utils/src/pm-action,v
retrieving revision 1.12
diff -u -r1.12 pm-action
--- src/pm-action	18 Jun 2007 20:42:36 -0000	1.12
+++ src/pm-action	24 Dec 2007 12:30:38 -0000
@@ -27,7 +27,7 @@
 # The rule here? Simplicity.
 
 help_options() {
-	echo "pm-action [options]"
+	echo "$(basename "$0") [options]"
 	echo
 	echo "Options can change how the supend or hibernate is done."
 	echo
Red Hat Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=302401
(Issue 1 in the bug report)
This patch makes sure that the nullglob option is set. This makes
sure that the result of a filename expansion is empty, when the
pattern does not match.

Index: pm/functions
===================================================================
RCS file: /cvs/pm-utils/pm-utils/pm/functions,v
retrieving revision 1.47
diff -u -r1.47 functions
--- pm/functions	23 Dec 2007 23:01:46 -0000	1.47
+++ pm/functions	24 Dec 2007 12:37:00 -0000
@@ -18,6 +18,10 @@
 [ -f /usr/lib/pm-utils/defaults ] && . /usr/lib/pm-utils/defaults
 set +a
 
+# set nullglob to make glob results empty in case the pattern does not
+# match any files
+shopt -s nullglob
+
 source_configs()
 {
 	cfgs="/etc/pm/config.d/*[^~]"
Index: src/pm-powersave
===================================================================
RCS file: /cvs/pm-utils/pm-utils/src/pm-powersave,v
retrieving revision 1.7
diff -u -r1.7 pm-powersave
--- src/pm-powersave	6 Mar 2007 19:08:06 -0000	1.7
+++ src/pm-powersave	24 Dec 2007 12:37:00 -0000
@@ -24,6 +24,10 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
 
+# set nullglob to make glob results empty in case the pattern does not
+# match any files
+shopt -s nullglob
+
 find_powerd_files()
 {
 	flist="/etc/pm/power.d/*[^~] /usr/lib/pm-utils/power.d/*[^~]"

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Pm-utils mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pm-utils

Reply via email to