From bee6665b88fca3b5e70e8b3c8f6281975721c7be Mon Sep 17 00:00:00 2001 From: Chris Dunlap Date: Thu, 11 Sep 2014 15:41:35 -0700 Subject: [PATCH] Fix zed io-spare.sh dash incompatibility The zed's io-spare.sh script defines a vdev_status() function to query the 'zpool status' output for obtaining the status of a specified vdev. This function contains a small awk script that uses a parameter expansion (${parameter/pattern/string}) supported in bash but not in dash. Under dash, this fails with a "Bad substitution" error. This commit replaces the awk script with a (hopefully more portable) sed script that has been tested under both bash and dash. Signed-off-by: Chris Dunlap Signed-off-by: Brian Behlendorf Closes #2536 --- cmd/zed/zed.d/io-spare.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/zed/zed.d/io-spare.sh b/cmd/zed/zed.d/io-spare.sh index dd5bf4e0f..894817317 100755 --- a/cmd/zed/zed.d/io-spare.sh +++ b/cmd/zed/zed.d/io-spare.sh @@ -54,10 +54,11 @@ flock -x 8 # Given a and return the status, (ONLINE, FAULTED, etc...). vdev_status() { local POOL=$1 - local VDEV=`basename $2` + local VDEV=$2 + local T=' ' # tab character since '\t' isn't portable - ${ZPOOL} status ${POOL} | \ - awk -v pat="${VDEV}|${VDEV/-part?}" '$0 ~ pat { print $1" "$2 }' + ${ZPOOL} status ${POOL} | sed -n -e \ + "s,^[ $T]*\(.*$VDEV\(-part[0-9]\+\)\?\)[ $T]*\([A-Z]\+\).*,\1 \3,p" return 0 }