find_module: use awk for processing, seems more portable than sed
authorMarko Kreen <markokr@gmail.com>
Tue, 15 Feb 2011 06:53:45 +0000 (08:53 +0200)
committerMarko Kreen <markokr@gmail.com>
Tue, 15 Feb 2011 07:14:03 +0000 (09:14 +0200)
find_modules.sh

index f0529cad3d9d4b1051a448f2512273eb2d176058..839f5bc0b333b0f2797828c0eb6f09653c3cee08 100755 (executable)
@@ -1,10 +1,9 @@
 #! /bin/sh
 
-top="$1"
-shift
-
 set -e
 
+top="$1"
+
 # sanity check
 test -n "$top" || {
   echo "usage: $0 USUAL_DIR SRC ..." >&2
@@ -14,17 +13,20 @@ test -f "$top/usual/base.h" || {
   echo "usage: $0 USUAL_DIR SRC ..." >&2
   exit 1
 }
+
+shift
 test -n "$1" || exit 0
 
 # return uniq module names, exclude already found ones
 grep_usual() {
   excl="nonex"
   for m in $m_done; do
-    excl="$excl\\|$m"
+    excl="$excl|$m"
   done
-  sed -n \
-    -e "/^#include[ \t]*[<\"]usual[/]\\($excl\\)[.]h/d" \
-    -e '/^#include[ \t]*[<"]usual[/]/  s,.*[<"]usual/\(.*\)[.]h[>"].*,\1,p' "$@" \
+  awk "
+/^#include[ \t]*[<\"]usual\\/($excl)[.]h/  { next; }
+/^#include[ \t]*[<\"]usual\\//             { split(\$0, tmp, \"[./]\"); print tmp[2]; }
+" "$@" \
   | sort -u
 }