slitaz-base-files rev 296

man: no choice if only one matching section
author Lucas Levrel <llevrel@yahoo.fr>
date Sat Jan 16 19:08:30 2016 +0100 (2016-01-16)
parents 9fd160a21243
children c18bf4a1a64c
files rootfs/usr/bin/man
line diff
     1.1 --- a/rootfs/usr/bin/man	Thu Jan 14 12:33:17 2016 +0100
     1.2 +++ b/rootfs/usr/bin/man	Sat Jan 16 19:08:30 2016 +0100
     1.3 @@ -134,9 +134,13 @@
     1.4  	SECTIONS=$(wget -q -O - http://linux.die.net/man/$LETTER.html | \
     1.5  		sed -n -r "s%.*href=\"(.)/$TOPIC\".*%\1%p")
     1.6  	[ -n "$SECTIONS" ] || { _ 'No manual entry for %s' "$TOPIC"; exit 0;}
     1.7 -	_n '%s found in the following sections:\n%s\nPlease choose one: ' "$TOPIC" \
     1.8 -		"$SECTIONS"
     1.9 -	read SECTION
    1.10 +	if [ $(printf '%s\n' "$SECTIONS"|wc -l) -eq 1 ]; then
    1.11 +		SECTION=$SECTIONS
    1.12 +	else
    1.13 +		_n '%s found in the following sections:\n%s\nPlease choose one: ' \
    1.14 +			"$TOPIC" "$SECTIONS"
    1.15 +		read SECTION
    1.16 +	fi
    1.17  fi
    1.18  
    1.19  MANURL="http://linux.die.net/man/$SECTION/$TOPIC"