From cd0973a87d41a7a90808024861aff1af4d4d3096 Mon Sep 17 00:00:00 2001 From: Thomas Bächler Date: Tue, 12 Jan 2010 21:18:57 +0100 Subject: Replace the custom 'replace' tool with 'sed' --- init | 23 ++++++++++++----------- load-modules.sh | 6 +++--- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/init b/init index 892e7fd..aa46c48 100644 --- a/init +++ b/init @@ -30,32 +30,33 @@ for cmd in ${CMDLINE}; do [0123456Ss]) ;; [0-9]*) ;; single) ;; - # only export stuff that does work with dash :) - *=*) cmd="$(replace -s= "${cmd}" '.' '_')" - cmd="$(replace -s= "${cmd}" '-' '_')" - export "${cmd}" + # only export stuff that does work with ash :) + *=*) rhs="$(echo "${cmd}" | cut -d= -f2-)" + cmd="$(echo "${cmd}" | cut -d= -f1 | sed 's|.|_|g')" + cmd="$(echo "${cmd}" | sed 's|-|_|g')=${rhs}" + (echo "${cmd}" | grep -qe '^[0-9]') || export "${cmd}" + ;; + *) cmd="$(echo "${cmd}" | sed 's|.|_|g')" + cmd="$(echo "${cmd}" | sed 's|-|_|g')" + (echo "${cmd}" | grep -qe '^[0-9]') || export "${cmd}=y" ;; - *) cmd="$(replace "${cmd}" '.' '_')" - cmd="$(replace "${cmd}" '-' '_')" - export "${cmd}=y" - ;; esac done if [ -n "${disablehooks}" ]; then - for d in $(replace "${disablehooks}" ','); do + for d in $(echo "${disablehooks}" | sed 's|,| |g'); do export "hook_${d}=disabled" done fi if [ -n "${disablemodules}" ]; then - for d in $(replace "${disablemodules}" ','); do + for d in $(echo "${disablemodules}" | sed 's|,| |g'); do export "mod_${d}=disabled" done fi if [ -n "${earlymodules}" ]; then - for m in $(replace "${earlymodules}" ','); do + for m in $(echo "${earlymodules}" | sed 's|,| |g'); do /sbin/modprobe -q ${m} > /dev/null 2>&1 done fi diff --git a/load-modules.sh b/load-modules.sh index 21767ca..f703088 100755 --- a/load-modules.sh +++ b/load-modules.sh @@ -7,7 +7,7 @@ MODPROBE="/sbin/modprobe" RESOLVEALIAS="/bin/resolve-modalias" USEBLACKLIST="--use-blacklist" -REPLACE="/bin/replace" +SED="/bin/sed" MODDEPS="/bin/moddeps" if [ -f /proc/cmdline ]; then @@ -19,12 +19,12 @@ if [ -f /proc/cmdline ]; then done #parse cmdline entries of the form "disablemodules=x,y,z" if [ -n "${disablemodules}" ]; then - BLACKLIST="$(${REPLACE} ${disablemodules} ',')" + BLACKLIST="$(echo "${disablemodules}" | ${SED} 's|,| |g')" fi fi # sanitize the module names -BLACKLIST="$(${REPLACE} "${BLACKLIST}" '-' '_')" +BLACKLIST="$(echo "${BLACKLIST}" | ${SED} 's|-|_|g')" if [ -n "${BLACKLIST}" ] ; then # Try to find all modules for the alias -- cgit v1.2.3-24-g4f1b