slitaz-base-files annotate rootfs/usr/bin/man @ rev 245
man: we dont need retawq for slitaz doc and read online man
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Thu May 01 08:32:54 2014 +0200 (2014-05-01) |
parents | 793c2b7ed97f |
children | 27287c7c55c9 |
rev | line source |
---|---|
pankso@67 | 1 #!/bin/sh |
pankso@67 | 2 # |
pankso@67 | 3 # Tiny man fake using online manuals. |
pascal@226 | 4 # Copyright (C) 2009-2014 SliTaz GNU/Linux. |
pankso@67 | 5 # |
pankso@139 | 6 . /lib/libtaz.sh |
pankso@67 | 7 |
al@179 | 8 # Internationalization. |
al@179 | 9 TEXTDOMAIN='slitaz-base' |
al@179 | 10 . /etc/locale.conf |
al@179 | 11 export TEXTDOMAIN LANG |
al@179 | 12 |
pankso@245 | 13 check_retawq() { |
pankso@245 | 14 if [ ! -x /usr/bin/retawq ]; then |
pankso@245 | 15 echo; _ "Missing Retawq web browser..." |
pankso@245 | 16 _ "Please run: su -c 'tazpkg get-install retawq'" |
pankso@245 | 17 exit 0 |
pankso@245 | 18 fi |
pankso@245 | 19 } |
pankso@67 | 20 |
pankso@67 | 21 local i |
pankso@67 | 22 local SECTION |
pankso@67 | 23 local MSG |
pankso@67 | 24 local TOPIC |
pankso@67 | 25 local MAN_SECTION |
pankso@67 | 26 |
pankso@67 | 27 case "$1" in |
pankso@67 | 28 ''|-*) |
al@219 | 29 emsg "$(_ '<b>Usage:</b> man [section] command')" |
pankso@67 | 30 return ;; |
pankso@67 | 31 esac |
pankso@67 | 32 |
pankso@67 | 33 SECTION=all |
pankso@67 | 34 MAN_SECTION='*' |
pankso@67 | 35 MSG="" |
pankso@67 | 36 |
pankso@67 | 37 if [ -n "$2" ]; then |
pankso@67 | 38 SECTION=$1 |
pankso@67 | 39 MAN_SECTION=$1 |
al@219 | 40 MSG=" $(_n 'in section $SECTION')" |
pankso@67 | 41 shift |
pankso@67 | 42 fi |
pankso@67 | 43 |
pankso@67 | 44 TOPIC=$1 |
pankso@67 | 45 |
pankso@245 | 46 if [ check_retawq -a -f /usr/share/doc/$TOPIC/$TOPIC.html ]; then |
pankso@67 | 47 retawq --dump=file:///usr/share/doc/$TOPIC/$TOPIC.html | less -M |
pankso@67 | 48 return |
pankso@245 | 49 elif [ check_retawq -a -f /usr/share/doc/slitaz/$TOPIC.html ]; then |
mojo@198 | 50 retawq --dump=file:///usr/share/doc/slitaz/$TOPIC.html | less -M |
mojo@198 | 51 return |
pankso@245 | 52 elif [ check_retawq -a -f /usr/share/doc/slitaz-tools/$TOPIC.html ]; then |
mojo@101 | 53 retawq --dump=file:///usr/share/doc/slitaz-tools/$TOPIC.html | less -M |
mojo@101 | 54 return |
pankso@139 | 55 elif [ -f /usr/share/doc/slitaz/$TOPIC.txt ]; then |
pankso@139 | 56 # SliTaz tools/libraries documentation (man a like format) |
pankso@139 | 57 less -M /usr/share/doc/slitaz/$TOPIC.txt |
pankso@139 | 58 return |
pankso@67 | 59 fi |
pankso@67 | 60 |
al@193 | 61 for i in /usr/share/man/$LC_ALL/man$MAN_SECTION /usr/share/man/man$MAN_SECTION; do |
al@194 | 62 if [ -f $i/$TOPIC.* ]; then |
al@194 | 63 i=$(ls $i/$TOPIC.* 2> /dev/null) |
al@194 | 64 if [ "x$i" != "x" ]; then |
al@194 | 65 case "$i" in |
al@194 | 66 *gz) (zcat $i || unlzma -c $i 2> /dev/null) | less -M;; |
al@194 | 67 *) less -M $i;; |
al@194 | 68 esac |
al@194 | 69 fi |
pankso@67 | 70 return |
pankso@67 | 71 fi |
pankso@245 | 72 if [ check_retawq -a -f $i/$TOPIC.html ]; then |
pankso@67 | 73 retawq --dump=file://$i/$TOPIC.html | less -M |
pankso@67 | 74 return |
pankso@67 | 75 fi |
pankso@67 | 76 done |
pankso@67 | 77 |
al@194 | 78 [ "x$SECTION" = "x" ] && SECTION="all" |
pankso@67 | 79 (wget -O - "http://mirror.slitaz.org/man/$SECTION/$TOPIC.html" || \ |
pankso@67 | 80 wget -O - "http://man.he.net/?topic=$TOPIC§ion=$SECTION") 2> /dev/null | \ |
al@219 | 81 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')\" }" | \ |
pankso@67 | 82 sed -e 's/<[^>]*>//g' -e 's/</</g' -e 's/>/>/g' -e 's/&/\&/g' | less -M |
pankso@67 | 83 |
pankso@67 | 84 exit 0 |