it is always a bad idea to mix up different languages in one environment. Another point is, to bury awk in base-files. There is no reason for it, these are only quick hacks from the old days of whiterussian 8-).
by using better varnames, the code is now readable. Signed-off-by: Bastian Bittorf <bittorf at bluebottle.com>
>From 41cf954a24faf211e6dd523c37dc074fd26391db Mon Sep 17 00:00:00 2001 From: Bastian Bittorf <[email protected]> Date: Sun, 16 Jan 2011 14:33:39 +0100 Subject: [PATCH] refactoring rootfs_type() without awk --- package/base-files/files/lib/upgrade/common.sh | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index 970016e..90fc642 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -102,8 +102,21 @@ v() { [ "$VERBOSE" -ge 1 ] && echo "$@" } -rootfs_type() { - mount | awk '($3 ~ /^\/$/) && ($5 !~ /rootfs/) { print $5 }' +rootfs_type() +{ + local line mountpoint fstype + + mount | while read line; do { + + set $line + mountpoint="$3" + fstype="$5" + + [ "$mountpoint" = "/" -a "$fstype" != "rootfs" ] && { + echo "$fstype" + return + } + } done } get_image() { # <source> [ <command> ] -- 1.6.3.3
_______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/mailman/listinfo/openwrt-devel
