From owner-svn-src-head@FreeBSD.ORG Wed Nov 20 21:05:34 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 328379E2; Wed, 20 Nov 2013 21:05:34 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 218AE299A; Wed, 20 Nov 2013 21:05:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rAKL5Y8N069412; Wed, 20 Nov 2013 21:05:34 GMT (envelope-from dteske@svn.freebsd.org) Received: (from dteske@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rAKL5XSw069410; Wed, 20 Nov 2013 21:05:33 GMT (envelope-from dteske@svn.freebsd.org) Message-Id: <201311202105.rAKL5XSw069410@svn.freebsd.org> From: Devin Teske Date: Wed, 20 Nov 2013 21:05:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r258401 - head/usr.sbin/bsdconfig/includes X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Nov 2013 21:05:34 -0000 Author: dteske Date: Wed Nov 20 21:05:33 2013 New Revision: 258401 URL: http://svnweb.freebsd.org/changeset/base/258401 Log: Add a `-d' flag for printing the description of each function. Modified: head/usr.sbin/bsdconfig/includes/USAGE head/usr.sbin/bsdconfig/includes/includes Modified: head/usr.sbin/bsdconfig/includes/USAGE ============================================================================== --- head/usr.sbin/bsdconfig/includes/USAGE Wed Nov 20 20:37:21 2013 (r258400) +++ head/usr.sbin/bsdconfig/includes/USAGE Wed Nov 20 21:05:33 2013 (r258401) @@ -28,6 +28,7 @@ Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS OPTIONS: -a Always use color even when output is not to a terminal. + -d Print the description for each function selected. -f Show functions for selected includes. -F pattern If `-f', only print functions matching pattern. Without `-f' @@ -64,3 +65,7 @@ EXAMPLES: bsdconfig @PROGRAM_NAME@ -F show common NB: The `.subr' suffix on the end of the include is optional. + + Show descriptions of each of the `show' functions: + + bsdconfig @PROGRAM_NAME@ -dfF show Modified: head/usr.sbin/bsdconfig/includes/includes ============================================================================== --- head/usr.sbin/bsdconfig/includes/includes Wed Nov 20 20:37:21 2013 (r258400) +++ head/usr.sbin/bsdconfig/includes/includes Wed Nov 20 21:05:33 2013 (r258401) @@ -29,7 +29,7 @@ ############################################################ INCLUDES # Prevent common.subr from auto initializing debugging (this is not an inter- -# active utility that requires debugging). +# active utility that requires debugging; also `-d' has been repurposed). # DEBUG_SELF_INITIALIZE=NO @@ -50,6 +50,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_ # Options # USE_COLOR=1 +SHOW_DESC= SHOW_FUNCS= FUNC_PATTERN= @@ -64,20 +65,33 @@ show_include() local file="${1#./}" local pattern="${FUNC_PATTERN:-.*}" - output=$( awk -v use_color=${USE_COLOR:-0} -v re="$pattern" ' + output=$( awk \ + -v use_color=${USE_COLOR:-0} \ + -v re="$pattern" \ + -v show_desc=${SHOW_DESC:-0} ' /^$/,/^#/ { if ($0 ~ /^# f_/) { if (!match($2, re)) next if (use_color) - printf " %s%s%s\n", + printf "+%s%s%s\n", substr($0, 2, RSTART), substr($0, 2 + RSTART, RLENGTH), substr($0, 2 + RSTART + RLENGTH) else print substr($0, 2) - print_more = substr($0, length($0)) == "\\" + if (show_desc) + print_more = 1 + else + print_more = substr($0, length($0)) == "\\" } - while (print_more) { + if (show_desc && print_more) { + getline + while ($0 ~ /^#/) { + print substr($0, 2) + getline + } + print_more = 0 + } else while (print_more) { getline print substr($0, 2) print_more = substr($0, length($0)) == "\\" @@ -89,10 +103,10 @@ show_include() return $SUCCESS fi if [ "$FUNC_PATTERN" ]; then - printf "$msg_functions_in_matching\n" \ + printf ">>> $msg_functions_in_matching\n" \ "$file" "$FUNC_PATTERN" else - printf "$msg_functions_in\n" "$file" + printf ">>> $msg_functions_in\n" "$file" fi echo "$output" echo # blank line to simplify awk(1)-based reparse @@ -110,9 +124,10 @@ show_include() # # Process command-line arguments # -while getopts afF:hn flag; do +while getopts adfF:hn flag; do case "$flag" in a) USE_COLOR=1 ;; + d) SHOW_DESC=1 ;; f) SHOW_FUNCS=1 ;; F) FUNC_PATTERN="$OPTARG" ;; n) USE_COLOR= ;;