[PATCH 3/3] scripts/bash_aliases: man_section(), man_lsfunc(), man_lsvar(): Use mansect(1)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Alejandro Colomar <alx@xxxxxxxxxx>
---
 scripts/bash_aliases | 38 ++++++--------------------------------
 1 file changed, 6 insertions(+), 32 deletions(-)

diff --git a/scripts/bash_aliases b/scripts/bash_aliases
index e461707c8..0b0b5e08a 100644
--- a/scripts/bash_aliases
+++ b/scripts/bash_aliases
@@ -40,35 +40,13 @@ sed_rm_ccomments()
 
 #  man_section()  prints specific manual page sections (DESCRIPTION, SYNOPSIS,
 # ...) of all manual pages in a directory (or in a single manual page file).
-# Usage example:  .../man-pages$ man_section man2 SYNOPSIS 'SEE ALSO';
+# Usage example:  .../man-pages$ man_section '\(SYNOPSIS\|SEE ALSO\)' man2/;
 
 man_section()
 {
-	if [ $# -lt 2 ]; then
-		>&2 echo "Usage: ${FUNCNAME[0]} <dir> <section>...";
-		return $EX_USAGE;
-	fi
-
-	local page="$1";
-	shift;
-	local sect="$*";
-
-	find "$page" -type f \
-	|xargs wc -l \
-	|grep -v -e '\b1 ' -e '\btotal\b' \
-	|awk '{ print $2 }' \
-	|sort \
-	|while read -r manpage; do
-		(sed -n '/^\.TH/,/^\.SH/{/^\.SH/!p}' <"$manpage";
-		 for s in $sect; do
-			<"$manpage" \
-			sed -n \
-				-e "/^\.SH $s/p" \
-				-e "/^\.SH $s/,/^\.SH/{/^\.SH/!p}";
-		 done;) \
-		|mandoc -Tutf8 2>/dev/null \
-		|col -pbx;
-	done;
+	mansect "$@" \
+	| mandoc -Tutf8 2>/dev/null \
+	| col -pbx;
 }
 
 #  man_lsfunc()  prints the name of all C functions declared in the SYNOPSIS
@@ -83,9 +61,7 @@ man_lsfunc()
 		return $EX_USAGE;
 	fi
 
-	for arg in "$@"; do
-		man_section "$arg" 'SYNOPSIS';
-	done \
+	man_section 'SYNOPSIS' "$@";
 	|sed_rm_ccomments \
 	|pcregrep -Mn '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]*?(...)?\s*\); *$' \
 	|grep '^[0-9]' \
@@ -106,9 +82,7 @@ man_lsvar()
 		return $EX_USAGE;
 	fi
 
-	for arg in "$@"; do
-		man_section "$arg" 'SYNOPSIS';
-	done \
+	man_section 'SYNOPSIS' "$@";
 	|sed_rm_ccomments \
 	|pcregrep -Mv '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]+?(...)?\s*\); *$' \
 	|pcregrep -Mn \
-- 
2.39.5

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux