summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarik Horn <[email protected]>2011-12-30 14:18:58 -0600
committerBrian Behlendorf <[email protected]>2012-01-11 11:56:56 -0800
commitb97f368d047943607b5b263331d7e2075ab3ffe8 (patch)
tree0db0ed41b0ab002141e4b3243788acc6ea48b017
parentab26409db753bb087842ab6f1af943f3386c764f (diff)
Avoid using awk in the zpool_id script.
Some implementations of `awk` incorrectly parse the \< and \> regex symbols, so use a `while read` loop and regular globbing instead. Signed-off-by: Brian Behlendorf <[email protected]> Closes: #259
-rwxr-xr-xcmd/zpool_id/zpool_id17
1 files changed, 13 insertions, 4 deletions
diff --git a/cmd/zpool_id/zpool_id b/cmd/zpool_id/zpool_id
index c65b1b5f4..bf15dc991 100755
--- a/cmd/zpool_id/zpool_id
+++ b/cmd/zpool_id/zpool_id
@@ -1,7 +1,6 @@
#!/bin/sh
CONFIG="${CONFIG:-/etc/zfs/zdev.conf}"
-AWK="${AWK:-/usr/bin/awk}"
if [ -z "${PATH_ID}" ]; then
# The path_id helper became a builtin command in udev 174.
@@ -63,9 +62,19 @@ fi
# configuration file which is of the format <device id> <key>.
# Lines starting with #'s are treated as comments and ignored.
# Exact matches are required, wild cards are not supported,
-# and only the first match is returned. Also note the following
-# regex pattern only appears to work with gawk, not mawk or awk.
-ID_ZPOOL=`${AWK} "/\<${ID_PATH}\>/ && !/^#/ { print \\$1; exit }" "${CONFIG}"`
+# and only the first match is returned.
+ID_ZPOOL=''
+while read CONFIG_ZPOOL CONFIG_PATH REPLY; do
+ if [ "${CONFIG_ZPOOL}" != "${CONFIG_ZPOOL#\#}" ]; then
+ # Skip comment lines.
+ continue
+ fi
+ if [ "${CONFIG_PATH}" = "${ID_PATH}" ]; then
+ ID_ZPOOL="${CONFIG_ZPOOL}"
+ break
+ fi
+done <"${CONFIG}"
+
[ -z "${ID_ZPOOL}" ] && die "Missing ID_ZPOOL for ID_PATH: ${ID_PATH}"
if [ -n "${ID_ZPOOL}" ]; then