]> granicus.if.org Git - zfs/commitdiff
vdev_id: use mawk-compatible regular expression
authorNed Bass <bass6@llnl.gov>
Wed, 17 Dec 2014 19:01:42 +0000 (11:01 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 19 Dec 2014 20:05:16 +0000 (12:05 -0800)
Slot mapping in vdev_id doesn't work on systems using mawk as the 'awk'
alternative. A regular expression in map_slot() contains an unquoted
empty string following the alternation (|) operator, which results in an
"missing operand" error with mawk. The solution is to rearrange the
expression so the alternation has two operands.

Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes zfsonlinux/pkg-zfs#136
Closes zfsonlinux/zfs#2965

cmd/vdev_id/vdev_id

index b6752ba1b08b9fbff048f9c4935934c4a80b2b4b..6fddd12f3348bff5bbc00945148500c7919f692c 100755 (executable)
@@ -116,7 +116,7 @@ map_slot() {
        local MAPPED_SLOT=
 
        MAPPED_SLOT=`awk "\\$1 == \"slot\" && \\$2 == ${LINUX_SLOT} && \
-                       \\$4 ~ /^(${CHANNEL}|)$/ { print \\$3; exit }" $CONFIG`
+                       \\$4 ~ /^${CHANNEL}$|^$/ { print \\$3; exit }" $CONFIG`
        if [ -z "$MAPPED_SLOT" ] ; then
                MAPPED_SLOT=$LINUX_SLOT
        fi