Author: lidl
Date: Mon Mar 11 13:33:03 2019
New Revision: 345005
URL: https://svnweb.freebsd.org/changeset/base/345005

Log:
  Remove an unneeded 'tail -n 1' from a pipeline
  
  When piping to awk, it's almost always an anti-pattern to use 'grep'
  first.
  
  When not in a pipeline, sometimes it is faster to use tail, as awk
  must process all the lines in the input stream, and won't 'seek'.
  In a pipeline, both grep and awk must process all lines, so we might
  as well skip the extra process creation for tail and just use awk
  for all the processing.
  
  Reviewed by:  jilles
  MFC after:    2 weeks
  Differential Revision:        https://reviews.freebsd.org/D19441

Modified:
  head/libexec/rc/rc.d/growfs

Modified: head/libexec/rc/rc.d/growfs
==============================================================================
--- head/libexec/rc/rc.d/growfs Mon Mar 11 10:42:09 2019        (r345004)
+++ head/libexec/rc/rc.d/growfs Mon Mar 11 13:33:03 2019        (r345005)
@@ -57,7 +57,7 @@ growfs_start ()
                ;;
        zfs)
                pool=${FSDEV%%/*}
-               rootdev=$(zpool list -v $pool | tail -n 1 | awk '{ print $1 }')
+               rootdev=$(zpool list -v $pool | awk 'END { print $1 }')
                ;;
        *)
                echo "Don't know how to grow root filesystem type: $FSTYPE"
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to