source: trunk/minix/commands/bzip2-1.0.3/bzmore@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

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