"Fossies" - the Fresh Open Source Software Archive

Member "grzip-0.3.0/scripts/grzmore" (31 Jan 2007, 1284 Bytes) of package /linux/privat/old/grzip-0.3.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 
    3 # Grzmore wrapped for grzip, 
    4 # adapted from zmore by Simon Matter <simon.matter@invoca.ch>
    5 # for Invoca Linux Server.
    6 
    7 PATH="/usr/bin:$PATH"; export PATH
    8 
    9 prog=`echo $0 | sed 's|.*/||'`
   10 case "$prog" in
   11     *less)  more=less   ;;
   12     *)  more=more       ;;
   13 esac
   14 
   15 if test "`echo -n a`" = "-n a"; then
   16   # looks like a SysV system:
   17   n1=''; n2='\c'
   18 else
   19   n1='-n'; n2=''
   20 fi
   21 oldtty=`stty -g 2>/dev/null`
   22 if stty -cbreak 2>/dev/null; then
   23   cb='cbreak'; ncb='-cbreak'
   24 else
   25   # 'stty min 1' resets eof to ^a on both SunOS and SysV!
   26   cb='min 1 -icanon'; ncb='icanon eof ^d'
   27 fi
   28 if test $? -eq 0 -a -n "$oldtty"; then
   29    trap 'stty $oldtty 2>/dev/null; exit' 0 2 3 5 10 13 15
   30 else
   31    trap 'stty $ncb echo 2>/dev/null; exit' 0 2 3 5 10 13 15
   32 fi
   33 
   34 if test $# = 0; then
   35     if test -t 0; then
   36     echo usage: $prog files...
   37     else
   38     grzip -c -d -f -q | eval $more
   39     fi
   40 else
   41     FIRST=1
   42     for FILE
   43     do
   44     if test $FIRST -eq 0; then
   45         echo $n1 "--More--(Next file: $FILE)$n2"
   46         stty $cb -echo 2>/dev/null
   47         ANS=`dd bs=1 count=1 2>/dev/null` 
   48         stty $ncb echo 2>/dev/null
   49         echo " "
   50         if test "$ANS" = 'e' -o "$ANS" = 'q'; then
   51             exit
   52         fi
   53     fi
   54     if test "$ANS" != 's'; then
   55         echo "------> $FILE <------"
   56         grzip -c -d -f -q "$FILE" | eval $more
   57     fi
   58     if test -t; then
   59         FIRST=0
   60     fi
   61     done
   62 fi