Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 May 2018 05:41:28 +0000 (UTC)
From:      Devin Teske <dteske@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r333514 - head/cddl/usr.sbin/dwatch
Message-ID:  <201805120541.w4C5fSWl027539@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dteske
Date: Sat May 12 05:41:28 2018
New Revision: 333514
URL: https://svnweb.freebsd.org/changeset/base/333514

Log:
  dwatch(1): Separate default values so `-[BK] num' don't affect usage
  
  If you were to pass an invalid option after `-B num' or `-K num' you
  would see that the usage statement would show the value you passed
  instead of the actual default.
  
  Moving the default values to separate variables that are unaffected
  by the options-parsing allows the usage statement to correctly show
  the hard-coded default values if no flags are used.
  
  Sponsored by:	Smule, Inc.

Modified:
  head/cddl/usr.sbin/dwatch/dwatch

Modified: head/cddl/usr.sbin/dwatch/dwatch
==============================================================================
--- head/cddl/usr.sbin/dwatch/dwatch	Sat May 12 05:36:47 2018	(r333513)
+++ head/cddl/usr.sbin/dwatch/dwatch	Sat May 12 05:41:28 2018	(r333514)
@@ -57,6 +57,12 @@ pgm="${0##*/}" # Program basename
 PROBE_ARG=
 
 #
+# Command-line defaults
+#
+_MAX_ARGS=64		# -B num
+_MAX_DEPTH=64		# -K num
+
+#
 # Command-line options
 #
 CONSOLE=		# -y
@@ -77,8 +83,8 @@ GROUP=			# -g group
 JID=			# -j jail
 LIST=			# -l
 LIST_PROFILES=		# -Q
-MAX_ARGS=64		# -B num
-MAX_DEPTH=64		# -K num
+MAX_ARGS=$_MAX_ARGS	# -B num
+MAX_DEPTH=$_MAX_DEPTH	# -K num
 ONELINE=		# -1
 OUTPUT=			# -o file
 OUTPUT_CMD=		# -O cmd
@@ -144,7 +150,7 @@ usage()
 	printf "$optfmt" "-1" \
 		"Print one line per process/profile (Default; disables \`-R')."
 	printf "$optfmt" "-B num" \
-		"Maximum process arguments to display (Default $MAX_ARGS)."
+		"Maximum process arguments to display (Default $_MAX_ARGS)."
 	printf "$optfmt" "-d" \
 		"Debug. Send dtrace(1) script to stdout instead of executing."
 	printf "$optfmt" "-e" \
@@ -162,7 +168,7 @@ usage()
 	printf "$optfmt" "-k name" \
 		"Only show processes matching name."
 	printf "$optfmt" "-K num" \
-		"Maximum directory depth to display (Default $MAX_DEPTH)."
+		"Maximum directory depth to display (Default $_MAX_DEPTH)."
 	printf "$optfmt" "-l" \
 		"List available probes on standard output and exit."
 	printf "$optfmt" "-m" \



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805120541.w4C5fSWl027539>