slitaz-base-files diff rootfs/usr/bin/man @ rev 266

man: tiny man fake update (thanks llev)
author Richard Dunbar <mojo@slitaz.org>
date Tue Mar 31 12:11:10 2015 -0400 (2015-03-31)
parents e970dc10e7e2
children 91fcb259b3bf
line diff
     1.1 --- a/rootfs/usr/bin/man	Thu May 01 08:32:54 2014 +0200
     1.2 +++ b/rootfs/usr/bin/man	Tue Mar 31 12:11:10 2015 -0400
     1.3 @@ -20,6 +20,7 @@
     1.4  
     1.5  local i
     1.6  local SECTION
     1.7 +local SECTIONS
     1.8  local MSG
     1.9  local TOPIC
    1.10  local MAN_SECTION
    1.11 @@ -75,10 +76,23 @@
    1.12  	fi
    1.13  done
    1.14  
    1.15 -[ "x$SECTION" = "x" ] && SECTION="all"
    1.16 -(wget -O - "http://mirror.slitaz.org/man/$SECTION/$TOPIC.html" || \
    1.17 -	wget -O - "http://man.he.net/?topic=$TOPIC&section=$SECTION") 2> /dev/null | \
    1.18 -	awk "BEGIN { s=0; n=0 } /<PRE>/ { s=1 } { if (s) { print; n++} } /<\/PRE>/ { s=0 } END { if (n == 0) print \"$(_ 'No manual entry for $TOPIC$MSG')\" }" | \
    1.19 -	sed -e 's/<[^>]*>//g' -e 's/&lt;/</g' -e 's/&gt;/>/g' -e 's/&amp;/\&/g' | less -M
    1.20 +if [ "$SECTION" = all ]
    1.21 +then SECTIONS="1 2 3 4 5 6 7 8"
    1.22 +else SECTIONS=$SECTION
    1.23 +fi
    1.24  
    1.25 +for SECTION in $SECTIONS
    1.26 +do
    1.27 +  URL=$( wget -q -O - http://man7.org/linux/man-pages/dir_all_alphabetic.html | \
    1.28 +        sed -n -r "s%.*href=\"\./(man./.*html)\">$TOPIC\($SECTION\).*%\1%p" )
    1.29 +  if [ -n "$URL" ]
    1.30 +  then
    1.31 +    wget -q -O - "http://man7.org/linux/man-pages/$URL" | \
    1.32 +    awk "BEGIN {s=0} /headline/{s=1} /COLOPHON/{s=0} {if(s) print}" | \
    1.33 +    sed -e 's%<span class="top-link">top</span>%%' -e 's/<[^>]*>//g' -e 's/&lt;/</g' \
    1.34 +        -e 's/&gt;/>/g' -e 's/&amp;/\&/g' -e 's/&nbsp;//g' | less -M
    1.35 +    exit 0
    1.36 +  fi
    1.37 +done
    1.38 +_ 'No manual entry for $TOPIC$MSG'
    1.39  exit 0