diff options
author | maximilian attems <maks@debian.org> | 2009-04-03 14:48:44 +0200 |
---|---|---|
committer | maximilian attems <maks@debian.org> | 2009-04-03 14:52:20 +0200 |
commit | d703b8ca26ac5230d7ffeae1891334791d8dab31 (patch) | |
tree | e16d11c8d6291b789269d510629e09108973296e /init | |
parent | e939f98f684326ddc06d54fe0379c552fb94010f (diff) | |
download | initramfs-tools-d703b8ca26ac5230d7ffeae1891334791d8dab31.tar.gz initramfs-tools-d703b8ca26ac5230d7ffeae1891334791d8dab31.zip |
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>
Diffstat (limited to 'init')
-rwxr-xr-x | init | 10 |
1 files changed, 3 insertions, 7 deletions
@@ -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}" |