modules.d: get rid of "tr"
authorHarald Hoyer <harald@redhat.com>
Wed, 27 Jun 2012 12:16:32 +0000 (14:16 +0200)
committerHarald Hoyer <harald@redhat.com>
Fri, 29 Jun 2012 10:41:27 +0000 (12:41 +0200)
replace it with sed or str_replace or bash ${var/a/b}

modules.d/10i18n/module-setup.sh
modules.d/40network/module-setup.sh
modules.d/40network/net-lib.sh
modules.d/40network/parse-bond.sh
modules.d/40network/parse-bridge.sh
modules.d/40network/parse-ifname.sh
modules.d/80cms/cms-write-ifcfg.sh
modules.d/80cms/module-setup.sh
modules.d/95dasd/module-setup.sh
modules.d/95zfcp/module-setup.sh
modules.d/95zfcp/zfcpconf.sh

index 7c8cd66..a7ddc82 100755 (executable)
@@ -31,7 +31,7 @@ install() {
             *) cmd=grep ;;
         esac
 
-        for INCL in $($cmd "^include " $MAP | cut -d' ' -f2 | tr -d '"'); do
+        for INCL in $($cmd "^include " $MAP | while read a a b; do echo ${a/\"/}; done); do
             for FN in $(find ${kbddir}/keymaps -type f -name $INCL\*); do
                 findkeymap $FN
             done
index 0ec6b4e..c69d81a 100755 (executable)
@@ -77,7 +77,7 @@ installkernel() {
 
 install() {
     local _arch _i _dir
-    dracut_install ip arping tr dhclient
+    dracut_install ip arping dhclient sed
     dracut_install -o brctl
     inst_script "$moddir/ifup.sh" "/sbin/ifup"
     inst_script "$moddir/netroot.sh" "/sbin/netroot"
index 7157cd5..9132e4d 100644 (file)
@@ -13,7 +13,7 @@ iface_for_remote_addr() {
 }
 
 iface_for_mac() {
-    local interface="" mac="$(echo $1 | tr '[:upper:]' '[:lower:]')"
+    local interface="" mac="$(echo $1 | sed 'y/ABCDEF/abcdef/')"
     for interface in /sys/class/net/*; do
         if [ $(cat $interface/address) = "$mac" ]; then
             echo ${interface##*/}
index 933ad27..983eb3a 100755 (executable)
@@ -32,8 +32,8 @@ parsebond() {
     case $# in
     0)  bondname=bond0; bondslaves="eth0 eth1" ;;
     1)  bondname=$1; bondslaves="eth0 eth1" ;;
-    2)  bondname=$1; bondslaves=$(echo $2|tr "," " ") ;;
-    3)  bondname=$1; bondslaves=$(echo $2|tr "," " "); bondoptions=$(echo $3|tr "," " ") ;;
+    2)  bondname=$1; bondslaves=$(str_replace "$2" "," " ") ;;
+    3)  bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " ") ;;
     *)  die "bond= requires zero to four parameters" ;;
     esac
 }
@@ -53,7 +53,7 @@ if getarg bond >/dev/null; then
         bondslaves="eth0 eth1"
     fi
     # Make it suitable for initscripts export
-    bondoptions=$(echo $bondoptions|tr ";" ",")
+    bondoptions=$(str_replace "$bondoptions" ";" ",")
     echo "bondname=$bondname" > /tmp/bond.info
     echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.info
     echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.info
index 5728fb6..1f027bb 100755 (executable)
@@ -29,7 +29,7 @@ parsebridge() {
     case $# in
         0)  bridgename=br0; ethnames=$iface ;;
         1)  die "bridge= requires two parameters" ;;
-        2)  bridgename=$1; ethnames=$(echo $2|tr "," " ") ;;
+        2)  bridgename=$1; ethnames=$(str_replace "$2" "," " ") ;;
         *)  die "bridge= requires two parameters" ;;
     esac
 }
index 26e6084..ce73a72 100755 (executable)
@@ -26,7 +26,7 @@ parse_ifname_opts() {
         7)
             ifname_if=$1
             # udev requires MAC addresses to be lower case
-            ifname_mac=`echo $2:$3:$4:$5:$6:$7 | tr '[:upper:]' '[:lower:]'`
+            ifname_mac=$(echo $2:$3:$4:$5:$6:$7 | sed 'y/ABCDEF/abcdef/')
             ;;
         *)
             die "Invalid arguments for ifname="
index 6349df3..6df6354 100755 (executable)
@@ -89,7 +89,7 @@ EOF
     for option in LAYER2 PORTNO; do
        [ -z "${!option}" ] && continue
        [ -n "$optstr" ] && optstr=${optstr}" "
-       optstr=${optstr}$(echo ${option} | tr [[:upper:]] [[:lower:]])"="${!option}
+       optstr=${optstr}$(echo ${option} | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')"="${!option}
     done
 # write single quotes since network.py removes double quotes but we need quotes
     echo "OPTIONS='$optstr'" >> $IFCFGFILE
index 87f34e3..69a20ad 100755 (executable)
@@ -24,7 +24,7 @@ install() {
     inst_hook pre-pivot 95 "$moddir/cms-write-ifcfg.sh"
     inst_script "$moddir/cmsifup.sh" /sbin/cmsifup
     dracut_install /etc/cmsfs-fuse/filetypes.conf /etc/udev/rules.d/99-fuse.rules /etc/fuse.conf \
-        cmsfs-fuse fusermount ulockmgr_server bash tr insmod rmmod cat normalize_dasd_arg \
+        cmsfs-fuse fusermount ulockmgr_server bash insmod rmmod cat normalize_dasd_arg sed \
         $(rpm -ql s390utils-base)
 
     inst_libdir_file "gconv/*"
index 74efc7b..62bf18c 100755 (executable)
@@ -18,7 +18,7 @@ installkernel() {
 
 install() {
     inst_hook cmdline 30 "$moddir/parse-dasd.sh"
-    dracut_install tr dasdinfo dasdconf.sh normalize_dasd_arg
+    dracut_install dasdinfo dasdconf.sh normalize_dasd_arg
     if [[ $hostonly ]]; then
         inst /etc/dasd.conf
     fi
index bbfdd27..fc8f422 100755 (executable)
@@ -22,7 +22,7 @@ installkernel() {
 
 install() {
     inst_hook cmdline 30 "$moddir/parse-zfcp.sh"
-    dracut_install tr zfcp_cio_free grep sed seq
+    dracut_install zfcp_cio_free grep sed seq
 
     inst_script /sbin/zfcpconf.sh
     inst_rules 56-zfcp.rules
index ceced35..7127eae 100755 (executable)
@@ -30,7 +30,7 @@ if [ -f "$CONFIG" ]; then
     if [ ! -d /sys/bus/ccw/drivers/zfcp ]; then
         return
     fi
-    tr "A-Z" "a-z" < $CONFIG| while read line; do
+    sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' < $CONFIG| while read line; do
     case $line in
         \#*) ;;
         *)