home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / gzip124.zip / gzip-1.2.4 / zmore.in < prev    next >
Text File  |  1993-08-17  |  1KB  |  53 lines

  1. :
  2. #!/bin/sh
  3.  
  4. PATH="BINDIR:$PATH"; export PATH
  5. if test "`echo -n a`" = "-n a"; then
  6.   # looks like a SysV system:
  7.   n1=''; n2='\c'
  8. else
  9.   n1='-n'; n2=''
  10. fi
  11. oldtty=`stty -g 2>/dev/null`
  12. if stty -cbreak 2>/dev/null; then
  13.   cb='cbreak'; ncb='-cbreak'
  14. else
  15.   # 'stty min 1' resets eof to ^a on both SunOS and SysV!
  16.   cb='min 1 -icanon'; ncb='icanon eof ^d'
  17. fi
  18. if test $? -eq 0 -a -n "$oldtty"; then
  19.    trap 'stty $oldtty 2>/dev/null; exit' 0 2 3 5 10 13 15
  20. else
  21.    trap 'stty $ncb echo 2>/dev/null; exit' 0 2 3 5 10 13 15
  22. fi
  23.  
  24. if test $# = 0; then
  25.     if test -t 0; then
  26.     echo usage: zmore files...
  27.     else
  28.     gzip -cdfq | eval ${PAGER-more}
  29.     fi
  30. else
  31.     FIRST=1
  32.     for FILE
  33.     do
  34.     if test $FIRST -eq 0; then
  35.         echo $n1 "--More--(Next file: $FILE)$n2"
  36.         stty $cb -echo 2>/dev/null
  37.         ANS=`dd bs=1 count=1 2>/dev/null` 
  38.         stty $ncb echo 2>/dev/null
  39.         echo " "
  40.         if test "$ANS" = 'e' -o "$ANS" = 'q'; then
  41.             exit
  42.         fi
  43.     fi
  44.     if test "$ANS" != 's'; then
  45.         echo "------> $FILE <------"
  46.         gzip -cdfq "$FILE" | eval ${PAGER-more}
  47.     fi
  48.     if test -t; then
  49.         FIRST=0
  50.     fi
  51.     done
  52. fi
  53.