[readonly/geninitrd/BUSYBOX: 11/113] change all 'grep' into 'awk'

draenog draenog at pld-linux.org
Sat Nov 2 19:10:57 CET 2013


commit 474f647f4dd158b389460ae14f4e9023dfea3744
Author: inglod <inglod at pld-linux.org>
Date:   Thu Nov 16 14:17:40 2000 +0000

    change all 'grep' into 'awk'
    
    
    svn-id: @1163

 geninitrd | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index a58caf4..ce224c6 100755
--- a/geninitrd
+++ b/geninitrd
@@ -99,7 +99,8 @@ findmodule() {
     fi
 
     # only need to add each module once
-    if echo $MODULES | grep $fmPath >/dev/null 2>&1 ; then : ; else
+    tmpFmPath=`echo $fmPath|awk -F/ '{for(i=1;i<NF;i++) { printf("%s\\/",$i); } { print $NF; }}'`
+    if is_yes "`echo $MODULES | awk '/"'$tmpFmPath'"/ { print "yes"; }' `" ; then : ; else
 	MODULES="$MODULES $fmPath"
     fi
 }
@@ -117,7 +118,7 @@ inst() {
 while [ $# -gt 0 ]; do
     case $1 in
 	--fstab*)
-	    if echo $1 | grep '=' >/dev/null ; then
+	    if is_yes "`echo $1 | awk '/=/ { print "yes"; }'`" ; then
 	    	fstab=`echo $1 | awk -F= '{print $2;}'`
 	    else
 		fstab=$2
@@ -126,7 +127,7 @@ while [ $# -gt 0 ]; do
 	    ;;
 
 	--with*)
-	    if echo $1 | grep '=' >/dev/null ; then
+	    if is_yes "`echo $1 | awk '/=/ { print "yes"; }'`" ; then
 	    	modname=`echo $1 | awk -F= '{print $2;}'`
 	    else
 		modname=$2
@@ -157,7 +158,7 @@ while [ $# -gt 0 ]; do
 	    force=1
 	    ;;
 	--preload)
-	    if echo $1 | grep '=' >/dev/null ; then
+	    if is_yes "`echo $1 | awk '/=/ { print "yes"; }'`" ; then
 	    	modname=`echo $1 | awk -F= '{print $2;}'`
 	    else
 		modname=$2
@@ -247,7 +248,7 @@ for n in $PREMODS; do
 done
 
 rootdev=$(awk '{ if ($2 == "/") { print $1; }}' $fstab)
-if is_yes "$PROBESCSI" && echo "$rootdev" | grep -q "^/dev/sd" ; then
+if is_yes "$PROBESCSI" && is_yes "`echo "$rootdev" | awk '/^\/dev\/sd/ { print "yes"; }'`" ; then
 
     for n in $PRESCSIMODS; do
 	if [ "$n" = "unknown" ] ; then
@@ -255,7 +256,7 @@ if is_yes "$PROBESCSI" && echo "$rootdev" | grep -q "^/dev/sd" ; then
         		modulefile=/etc/conf.modules
     		fi
     		if [ -f $modulefile ]; then
-			scsimodules=`grep scsi_hostadapter $modulefile | grep -v '^[ 	]*#' | LC_ALL=C sort -u | awk '{ print $3 }'`
+			scsimodules=`awk '/scsi_hostadapter/ && ! /^[\t ]*#/ { print $3; }' $modulefile| LC_ALL=C sort -u`
 			for n in $scsimodules; do
     		# for now allow scsi modules to come from anywhere.  There are some
     		# RAID controllers with drivers in block/
@@ -269,7 +270,7 @@ if is_yes "$PROBESCSI" && echo "$rootdev" | grep -q "^/dev/sd" ; then
 
 fi
 
-if is_yes "$PROBEIDE" && echo "$rootdev" | grep -q "^/dev/hd" ; then
+if is_yes "$PROBEIDE" && is_yes "`echo "$rootdev" | awk '/^\/dev\/hd/ { print "yes"; }'`" ; then
     for n in $PREIDEMODS; do
 	    findmodule $n
     done
@@ -277,9 +278,8 @@ fi
 
 if is_yes "$PROBERAID" ; then
     # load appropriate raid devices if necessary
-    if grep '^/dev/md' $fstab | grep -v noauto >/dev/null 2>&1 ; then
-	for number in $(grep '^[ 	]*raid-level' /etc/raidtab |
-			  awk '{print $2}' | LC_ALL=C sort -u) ; do
+    if is_yes "`awk '/^\/dev\/md/ && ! /noauto/ { print "yes"; }' $fstab`" ; then
+	for number in $(awk '/^[\t ]*raid-level/ { print $2; }' /etc/raidtab | LC_ALL=C sort -u) ; do
 	    case $number in
 	    [0145])
 		findmodule raid$number
@@ -293,15 +293,15 @@ if is_yes "$PROBERAID" ; then
 fi
 
 # check to see if we need to set up a loopback filesystem
-if echo $rootdev | cut -d/ -f3 | grep loop >/dev/null; then
+if is_yes "`echo $rootdev | cut -d/ -f3 | awk '/loop/ { print "yes"; }'`" ; then
     key="^# $(echo $rootdev | cut -d/ -f3 | tr '[a-z]' '[A-Z]'):"
-    if ! grep "$key" $fstab > /dev/null; then
+    if ! is_yes "`awk '/'$key'/ { print( "yes"); }' $fstab`" ; then
 	echo "The root filesystem is on a $rootdev, but there is no magic entry in $fstab" 1>&2
 	echo "for this device. Consult the geninitrd man page for more information" 2>&2
 	exit 1
     fi
 
-    line=$(grep "$key" $fstab)
+    line=`awk '/'$key'/ { print $0; }' $fstab`
     loopDev=$(echo $line | awk '{print $3}')
     loopFs=$(echo $line | awk '{print $4}')
     loopFile=$(echo $line | awk '{print $5}')
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/readonly/geninitrd.git/commitdiff/0999a53e93eedcf489380684b998ce04aaddf11c



More information about the pld-cvs-commit mailing list