slitaz-base-files view rootfs/usr/bin/man @ rev 272
Update translations to use "%s" form instead of "$variable"
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Mon May 25 21:14:15 2015 +0300 (2015-05-25) |
parents | 27287c7c55c9 |
children | eecec1b9437a |
line source
1 #!/bin/sh
2 #
3 # Tiny man fake using online manuals.
4 # Copyright (C) 2009-2015 SliTaz GNU/Linux.
5 #
6 . /lib/libtaz.sh
8 # Internationalization.
9 TEXTDOMAIN='slitaz-base'
10 . /etc/locale.conf
11 export TEXTDOMAIN LANG
13 check_retawq() {
14 if [ ! -x /usr/bin/retawq ]; then
15 echo; _ "Missing Retawq web browser..."
16 _ 'Please run: %s' "su -c 'tazpkg get-install retawq'"
17 exit 0
18 fi
19 }
21 local i SECTION SECTIONS MSG TOPIC MAN_SECTION
23 case "$1" in
24 ''|-*)
25 emsg "$(_ '<b>Usage:</b> man [section] command')"
26 return ;;
27 esac
29 SECTION='all'
30 MAN_SECTION='*'
31 MSG=''
33 if [ -n "$2" ]; then
34 SECTION="$1"
35 MAN_SECTION="$1"
36 MSG=" $(_n 'in section %s' "$SECTION")"
37 shift
38 fi
40 TOPIC="$1"
42 if [ check_retawq -a -f /usr/share/doc/$TOPIC/$TOPIC.html ]; then
43 retawq --dump=file:///usr/share/doc/$TOPIC/$TOPIC.html | less -M
44 return
45 elif [ check_retawq -a -f /usr/share/doc/slitaz/$TOPIC.html ]; then
46 retawq --dump=file:///usr/share/doc/slitaz/$TOPIC.html | less -M
47 return
48 elif [ check_retawq -a -f /usr/share/doc/slitaz-tools/$TOPIC.html ]; then
49 retawq --dump=file:///usr/share/doc/slitaz-tools/$TOPIC.html | less -M
50 return
51 elif [ -f /usr/share/doc/slitaz/$TOPIC.txt ]; then
52 # SliTaz tools/libraries documentation (man a like format)
53 less -M /usr/share/doc/slitaz/$TOPIC.txt
54 return
55 fi
57 for i in /usr/share/man/$LC_ALL/man$MAN_SECTION /usr/share/man/man$MAN_SECTION; do
58 if [ -f $i/$TOPIC.* ]; then
59 i=$(ls $i/$TOPIC.* 2> /dev/null)
60 if [ "x$i" != "x" ]; then
61 case "$i" in
62 *gz) (zcat $i || unlzma -c $i 2>/dev/null) | less -M;;
63 *) less -M $i;;
64 esac
65 fi
66 return
67 fi
68 if [ check_retawq -a -f $i/$TOPIC.html ]; then
69 retawq --dump=file://$i/$TOPIC.html | less -M
70 return
71 fi
72 done
74 if [ "$SECTION" == 'all' ]
75 then SECTIONS='1 2 3 4 5 6 7 8'
76 else SECTIONS="$SECTION"
77 fi
79 for SECTION in $SECTIONS; do
80 URL=$( wget -q -O - http://man7.org/linux/man-pages/dir_all_alphabetic.html | \
81 sed -n -r "s%.*href=\"\./(man./.*html)\">$TOPIC\($SECTION\).*%\1%p" )
82 if [ -n "$URL" ]
83 then
84 wget -q -O - "http://man7.org/linux/man-pages/$URL" | \
85 awk "BEGIN {s=0} /headline/{s=1} /COLOPHON/{s=0} {if(s) print}" | \
86 sed -e 's%<span class="top-link">top</span>%%' -e 's/<[^>]*>//g' -e 's/</</g' \
87 -e 's/>/>/g' -e 's/&/\&/g' -e 's/ //g' | less -M
88 exit 0
89 fi
90 done
91 _ 'No manual entry for %s' "$TOPIC$MSG"
92 exit 0