Skip to content

Commit

Permalink
Fix zed io-spare.sh dash incompatibility
Browse files Browse the repository at this point in the history
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 <cdunlap@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2536
  • Loading branch information
dun authored and behlendorf committed Sep 23, 2014
1 parent 36283ca commit bee6665
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/zed/zed.d/io-spare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ flock -x 8
# Given a <pool> and <device> 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
}

Expand Down

0 comments on commit bee6665

Please sign in to comment.