Skip to content

Commit

Permalink
Fix awk usage
Browse files Browse the repository at this point in the history
The zpool_id and zpool_layout helper scripts have been updated to
use the more common /usr/bin/awk symlink.  On Fedora/Redhat systems
there are both /bin/awk and /usr/bin/awk symlinks to your installed
version of awk.  On Debian/Ubuntu systems only the /usr/bin/awk
symlink exists.

Additionally, add the '\<' token to the beginning of the regex
pattern to prevent partial matches.  This pattern only appears to
work with gawk despite the mawk man page claiming to support this
extended regex.  Thus you will need to have gawk installed to use
these optional helper scripts.  A comment has been added to the
script to reflect this reality.
  • Loading branch information
behlendorf committed May 6, 2011
1 parent 34b84cb commit 6ee44e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions cmd/zpool_id/zpool_id
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

CONFIG=${CONFIG:-/etc/zfs/zdev.conf}
PATH_ID=${PATH_ID:-/lib/udev/path_id}
AWK=${AWK:-/bin/awk}
AWK=${AWK:-/usr/bin/awk}

die() {
echo "Error: $*"
Expand Down Expand Up @@ -47,8 +47,9 @@ eval `${PATH_ID} ${DEVICE}`
# 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.
ID_ZPOOL=`${AWK} "/${ID_PATH}\>/ && !/^#/ { print \\$1; exit }" ${CONFIG}`
# 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}`
[ -z ${ID_ZPOOL} ] && die "Missing ID_ZPOOL for ID_PATH: ${ID_PATH}"

if [ ${ID_ZPOOL} ]; then
Expand Down
2 changes: 1 addition & 1 deletion cmd/zpool_layout/zpool_layout
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# /etc/zfs/zdev.conf file, it allows the by-path naming convertion
# to change and still keep the simple <channel><rank> naming.
#
AWK=${AWK:-/bin/awk}
AWK=${AWK:-/usr/bin/awk}
CONFIG=${CONFIG:-/etc/zfs/zdev.conf}
BUSES=( 01 02 03 )
PORTS=( 4 0 )
Expand Down

0 comments on commit 6ee44e3

Please sign in to comment.