[PATCH 2/4] hal-info: Clean up keymap-check.sh

Victor Lowther victor.lowther at gmail.com
Mon Mar 24 20:08:15 PDT 2008


Further cleanups in keymap-check.sh.

Remove temporary file in a trap 0.  That way the temp file will be removed
no matter how we exit the script.

Get rid of extraneous postprocessing in the main body of the program.
All that really was needed was for get_files to return 1 if any file failed
processing.
---
 tools/keymap-check.sh |   27 ++++++++-------------------
 1 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/tools/keymap-check.sh b/tools/keymap-check.sh
index 76f5c24..881f7bc 100755
--- a/tools/keymap-check.sh
+++ b/tools/keymap-check.sh
@@ -17,15 +17,14 @@ get_line ()
 		s,[^:]*:,,;   		# get rid of leading cruft
 		p };' "$1" | while read data;
 	do
-		if isin $data; then
-			echo "$data "
-		fi
+		isin $data && echo "$data "
 	done
 }
 
 # processes each line of the fdi file
 get_files ()
 {
+	local retval=0
 	for file in "../fdi/information/10freedesktop/30-keymap-"*".fdi";
 	do
 		status="ok"
@@ -36,13 +35,12 @@ get_files ()
 		fi
 		echo "Validate keycode in ${file} : ${status}"
 		if [ ! -z "$ret" ]; then
-			echo "$ret" | xargs
+			echo "$ret"
 		fi
 	done
+	return $retval
 }
 
-retval=0
-
 # look for a hal install with gperf
 fqpath="../../hal/tools/hal-setup-keymap-keys.txt"
 if [ ! -e "$fqpath" ]; then
@@ -54,17 +52,8 @@ fi
 # make lowercase and save in /tmp
 tr '[A-Z]' '[a-z]' < "$fqpath" | sort > /tmp/quirk-keymap-list.txt
 
-echo "Validating keycodes..."
-result=`get_files`
-echo "$result"
-
-if [ ! -z "`echo $result | grep FAILED`" ]; then
-	retval=1
-fi
-
-if [ -e /tmp/quirk-keymap-list.txt ]; then
-	rm -rf /tmp/quirk-keymap-list.txt
-fi
-
-exit $retval
+# remove tmp keycodes no matter how they exit
+trap 'rm -f /tmp/quirk-keymap-list.txt' 0
 
+echo "Validating keycodes..."
+get_files
-- 
1.5.4.3



More information about the hal mailing list