home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-User.iso / usr / bin / zmore < prev    next >
Text File  |  1997-03-28  |  1KB  |  48 lines

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