[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#222943: modconf: Getting ride of the sed dependency (as seen in the TODO File) [patch included]



Package: modconf
Version: 0.2.44
Severity: normal
Tags: patch

Hello,

I read in the TODO list (modconf Source) that you want to get ride of 
the sed dependency.
So I had a try.

I only wasn't able to change the first occurence in the file modconf 
because I have an different layout in /etc/locale.alias and so didn't 
get the sense of the command.

But the rest of my patch seems to work.

Greetings
	Thomas Braun


-- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux thomas 2.4.22 #1 Fre Nov 21 11:37:27 CET 2003 i686
Locale: LANG=de_DE@euro, LC_CTYPE=de_DE@euro

Versions of packages modconf depends on:
ii  modutils                     2.4.25-3    Linux module utilities
ii  whiptail                     0.50.17-9.6 Displays user-friendly 
dialog boxe
ii  whiptail [whiptail-provider] 0.50.17-9.6 Displays 
user-friendlydialog boxe
--- modconf-0.2.44/modules/params	Mon Mar 25 06:03:45 2002
+++ modconf-0.2.44_sed/modules/params	Fri Dec  5 01:24:18 2003
@@ -23,12 +23,6 @@
     readonly extract="cpio -i -d"
 fi
 
-if [ -x $Target/bin/sed ]; then
-    readonly sed="$Target/bin/sed"
-else 
-    readonly sed="sed"
-fi
-
 if [ -x /bin/tempfile -o -x /usr/bin/tempfile ]; then
     readonly TempFile=`tempfile`
     readonly TempFile1=`tempfile`
@@ -37,12 +31,12 @@
     readonly TempFile4=`tempfile`
     readonly TempFile5=`tempfile`
 else 
-    readonly TempFile="/tmp/`echo $0|$sed -e 's/^.*\///'`.$$"
-    readonly TempFile1="/tmp/`echo $0|$sed -e 's/^.*\///'`.$$.1"
-    readonly TempFile2="/tmp/`echo $0|$sed -e 's/^.*\///'`.$$.2"
-    readonly TempFile3="/tmp/`echo $0|$sed -e 's/^.*\///'`.$$.3"
-    readonly TempFile4="/tmp/`echo $0|$sed -e 's/^.*\///'`.$$.4"
-    readonly TempFile5="/tmp/`echo $0|$sed -e 's/^.*\///'`.$$.5"
+    readonly TempFile="/tmp/`echo ${0##*/}`.$$"
+    readonly TempFile1="/tmp/`echo ${0##*/}`.$$.1"
+    readonly TempFile2="/tmp/`echo ${0##*/}`.$$.2"
+    readonly TempFile3="/tmp/`echo${0##*/}`.$$.3"
+    readonly TempFile4="/tmp/`echo ${0##*/}`.$$.4"
+    readonly TempFile5="/tmp/`echo${0##*/}`.$$.5"
 fi
 
 KernelVersion=$(uname -r)
--- modconf-0.2.44/modconf	Sun Jan 27 22:43:36 2002
+++ modconf-0.2.44_sed/modconf	Fri Dec  5 02:07:57 2003
@@ -10,6 +10,9 @@
 umask 022
 
 # preparations, resolve the LANG alias
+
+## Don't unterstand the next if command because my Woody System has a different Layout in /etc/locale.alias
+
 if [ -n "$LANG" ] ; then
    if grep "^$LANG" /etc/locale.alias >/dev/null 2>&1; then
       export LANG=$(grep "^$LANG" /etc/locale.alias| sed -e 's/.*\(.._.*\).*/\1/')
@@ -21,12 +24,13 @@
     . $ModuleHelpDir/eval_C
   else
     if [ -n "$LC_MESSAGES" ]; then
-       LINGUA=$(echo $LC_MESSAGES | $sed -e 's/_.*//')
+         LINGUA=${LC_MESSAGES%%_*}
        if (echo $LC_MESSAGES | grep -i '\.utf.8' > /dev/null) ; then
          LINGUA=$LINGUA.utf-8
        fi
     else
-       LINGUA=$(echo $LANG | $sed -e 's/_.*//')
+       LINGUA=${LANG%%_*}
+
        if (echo $LANG | grep -i '\.utf.8' > /dev/null) ; then
          LINGUA=$LINGUA.utf-8
        fi
@@ -132,8 +136,8 @@
 
     eval "summary=$`echo dir_descr_$tdir`"
 
-    summary=$(echo $summary | sed -e 's/^-\(.*\)/\1/')
-    echo "\"$directory\"" \\ >> $TempFile
+     summary=${summary#-}
+   echo "\"$directory\"" \\ >> $TempFile
     echo "\"$summary."\" \\ >> $TempFile
   done
   echo "" >> $TempFile
--- modconf-0.2.44/modules/util	Sun Feb  3 18:50:06 2002
+++ modconf-0.2.44_sed/modules/util	Fri Dec  5 01:04:52 2003
@@ -26,7 +26,12 @@
 }
 
 mkmodulevarname () {
-    echo $1 | $sed 's/[-+,]/_/g'
+       local module=$1
+       module=${module//-/_}
+       module=${module//+/_}
+       module=${module//,/_}
+       echo $module
+
 }
 
 basemodulename () {
@@ -50,7 +55,7 @@
 
 build_lists () {
     if [ -f /proc/modules ]; then
-	installed_module_list="$(sed -e 's/\([^ 	]\)[ 	].*/\1/' < /proc/modules)"
+	installed_module_list="$(cut -f1 "-d " /proc/modules)"
     fi
     return 0;
 }
@@ -85,7 +90,7 @@
   if [ ! -e $ModuleHelpDir/descr.gz ]; then
     return
   fi
-  zcat $ModuleHelpDir/descr.gz | $sed -e 's/^#.*//' \
+  zcat $ModuleHelpDir/descr.gz | grep -v ^#.* \
     | (IFS=\n; retcode=0;
         while read line ; do
           case $line in
@@ -275,8 +280,11 @@
   else
     arguments=''
   fi
+  
+    arguments=${arguments//  }
+    argmuents=${arguments// =/=}
+    argmuents=${arguments//= /=}
 
-  arguments=$(echo $arguments|$sed 's/ *= */=/g')
   update_modules_conf "$module" "$arguments"
 }
 
@@ -383,7 +391,7 @@
   fi
   if [ -f $MODULESFILE ]; then
     rm -f $MODULESFILE.tmp
-    $sed -e /^$module\$/d < $MODULESFILE >$MODULESFILE.tmp
+    grep -v ^$module\$ < $MODULESFILE >$MODULESFILE.tmp
     if [ $? -ne 0 ]; then return 1; fi
     chown 0.0 $MODULESFILE.tmp
     chmod 644 $MODULESFILE.tmp

Reply to: