slitaz-base-files rev 39
add default man command in /etc/profile
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Jul 16 09:49:08 2008 +0000 (2008-07-16) |
parents | d9469dd5238d |
children | 481a7361007f |
files | rootfs/etc/profile |
line diff
1.1 --- a/rootfs/etc/profile Tue Jun 24 09:27:49 2008 +0000 1.2 +++ b/rootfs/etc/profile Wed Jul 16 09:49:08 2008 +0000 1.3 @@ -24,6 +24,52 @@ 1.4 # 1.5 which ldd > /dev/null || alias ldd='/lib/ld*.so --list' 1.6 1.7 +# man fake 1.8 +# 1.9 +if [ ! -x /usr/bin/man ]; then 1.10 + 1.11 +man() 1.12 +{ 1.13 +local i 1.14 +local SECTION 1.15 +local MSG 1.16 +local TOPIC 1.17 +local MAN_SECTION 1.18 +case "$1" in 1.19 +''|-*) 1.20 + cat <<EOT 1.21 + Usage: man [section] command 1.22 +EOT 1.23 + return;; 1.24 +esac 1.25 +SECTION=all 1.26 +MAN_SECTION='*' 1.27 +MSG="" 1.28 +if [ -n "$2" ]; then 1.29 + SECTION=$1 1.30 + MAN_SECTION=$1 1.31 + MSG=" in section $SECTION" 1.32 + shift 1.33 +fi 1.34 +TOPIC=$1 1.35 +if [ -f /usr/share/doc/$TOPIC/$TOPIC.html ]; then 1.36 + retawq --dump=file:///usr/share/doc/$TOPIC/$TOPIC.html | less -M 1.37 + return 1.38 +fi 1.39 +for i in /usr/share/$LC_ALL/man$MAN_SECTION /usr/share/man$MAN_SECTION; do 1.40 + if [ -f $i/$TOPIC.* ]; then 1.41 + (zcat $i/$TOPIC.* || unlzma -c $i/$TOPIC.* 2>/dev/null)|less -M 1.42 + return 1.43 + fi 1.44 +done 1.45 +wget -O - "http://man.he.net/?topic=$TOPIC§ion=$SECTION" 2> /dev/null | \ 1.46 + 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.47 + sed -e 's/<[^>]*>//g' -e 's/</</g' -e 's/>/>/g' -e 's/&/\&/g' | less -M 1.48 +} 1.49 + 1.50 +fi 1.51 + 1.52 + 1.53 # Export all variables definied above and set mask. 1.54 # 1.55 export PATH LD_LIBRARY_PATH PS1 DISPLAY G_FILENAME_ENCODING ignoreeof