summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormaximilian attems <maks@debian.org>2009-04-03 14:48:44 +0200
committermaximilian attems <maks@debian.org>2009-04-03 14:52:20 +0200
commitd703b8ca26ac5230d7ffeae1891334791d8dab31 (patch)
treee16d11c8d6291b789269d510629e09108973296e
parente939f98f684326ddc06d54fe0379c552fb94010f (diff)
cleanup LABEL handling code
make it more concise: * use POSIX ${parameter:+word} * replace *[/]*) by just */*) * test exit code of command -v rather then running test -x on it while we are at it fix another command -v usage in scripts/functions. Reviewed-by: Colin Watson <cjwatson@ubuntu.com> Signed-off-by: maximilian attems <maks@debian.org>
-rwxr-xr-xinit10
-rw-r--r--scripts/functions2
-rwxr-xr-xscripts/local-premount/resume10
3 files changed, 7 insertions, 15 deletions
diff --git a/init b/init
index a149c2b..e8c97a5 100755
--- a/init
+++ b/init
@@ -67,8 +67,8 @@ for x in $(cat /proc/cmdline); do
# support any / in LABEL= path (escape to \x2f)
case "${ROOT}" in
- *[/]*)
- if [ -x "$(command -v sed)" ]; then
+ */*)
+ if command -v sed >/dev/null 2>&1; then
ROOT="$(echo ${ROOT} | sed 's,/,\\x2f,g')"
else
if [ "${ROOT}" != "${ROOT#/}" ]; then
@@ -80,11 +80,7 @@ for x in $(cat /proc/cmdline); do
IFS='/'
newroot=
for s in $ROOT; do
- if [ -z "${newroot}" ]; then
- newroot="${s}"
- else
- newroot="${newroot}\\x2f${s}"
- fi
+ newroot="${newroot:+${newroot}\\x2f}${s}"
done
unset IFS
ROOT="${newroot}"
diff --git a/scripts/functions b/scripts/functions
index b813529..77de8f3 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -304,6 +304,6 @@ configure_networking()
# Wait for queued kernel/udev events
wait_for_udev()
{
- [ -x "$(command -v udevadm)" ] || return 0
+ command -v udevadm >/dev/null 2>&1 || return 0
udevadm settle ${1:+--timeout=$1}
}
diff --git a/scripts/local-premount/resume b/scripts/local-premount/resume
index b2b0e1d..11acfc7 100755
--- a/scripts/local-premount/resume
+++ b/scripts/local-premount/resume
@@ -25,8 +25,8 @@ LABEL=*)
# support any / in LABEL= path (escape to \x2f)
case "${resume}" in
- *[/]*)
- if [ -x "$(command -v sed)" ]; then
+ */*)
+ if command -v sed >/dev/null 2>&1; then
resume="$(echo ${resume} | sed 's,/,\\x2f,g')"
else
if [ "${resume}" != "${resume#/}" ]; then
@@ -38,11 +38,7 @@ LABEL=*)
IFS='/'
newresume=
for s in $resume; do
- if [ -z "${newresume}" ]; then
- newresume="${s}"
- else
- newresume="${newresume}\\x2f${s}"
- fi
+ newresume="${newresume:+${newresume}\\x2f}${s}"
done
unset IFS
resume="${newresume}"