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 <behlendorf1@llnl.gov>
Closes: #259
This commit is contained in:
Darik Horn 2011-12-30 14:18:58 -06:00 committed by Brian Behlendorf
parent ab26409db7
commit b97f368d04

View File

@ -1,7 +1,6 @@
#!/bin/sh #!/bin/sh
CONFIG="${CONFIG:-/etc/zfs/zdev.conf}" CONFIG="${CONFIG:-/etc/zfs/zdev.conf}"
AWK="${AWK:-/usr/bin/awk}"
if [ -z "${PATH_ID}" ]; then if [ -z "${PATH_ID}" ]; then
# The path_id helper became a builtin command in udev 174. # 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>. # configuration file which is of the format <device id> <key>.
# Lines starting with #'s are treated as comments and ignored. # Lines starting with #'s are treated as comments and ignored.
# Exact matches are required, wild cards are not supported, # Exact matches are required, wild cards are not supported,
# and only the first match is returned. Also note the following # and only the first match is returned.
# regex pattern only appears to work with gawk, not mawk or awk. ID_ZPOOL=''
ID_ZPOOL=`${AWK} "/\<${ID_PATH}\>/ && !/^#/ { print \\$1; exit }" "${CONFIG}"` 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}" [ -z "${ID_ZPOOL}" ] && die "Missing ID_ZPOOL for ID_PATH: ${ID_PATH}"
if [ -n "${ID_ZPOOL}" ]; then if [ -n "${ID_ZPOOL}" ]; then