[BACK]Return to zmore CVS log [TXT][DIR] Up to [local] / src / usr.bin / compress

Annotation of src/usr.bin/compress/zmore, Revision 1.8

1.3       millert     1: #!/bin/sh -
1.1       millert     2: #
1.8     ! millert     3: # $OpenBSD: zmore,v 1.7 2014/05/07 21:42:50 zhuk Exp $
1.4       otto        4: #
1.1       millert     5: # Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
                      6: #
                      7: # Permission to use, copy, modify, and distribute this software for any
                      8: # purpose with or without fee is hereby granted, provided that the above
                      9: # copyright notice and this permission notice appear in all copies.
                     10: #
                     11: # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     12: # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     13: # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     14: # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     15: # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     16: # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     17: # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     18: #
                     19: # Sponsored in part by the Defense Advanced Research Projects
                     20: # Agency (DARPA) and Air Force Research Laboratory, Air Force
                     21: # Materiel Command, USAF, under agreement number F39502-99-1-0512.
                     22: #
                     23:
                     24: # Pull out any command line flags so we can pass them to more/less
                     25: flags=
                     26: while test $# -ne 0; do
                     27:        case "$1" in
                     28:                --)
                     29:                        shift
                     30:                        break
                     31:                        ;;
1.8     ! millert    32:                -*|+*)
1.1       millert    33:                        flags="$flags $1"
                     34:                        shift
                     35:                        ;;
                     36:                *)
                     37:                        break
                     38:                        ;;
                     39:        esac
                     40: done
                     41:
1.5       jsg        42: if [ `basename $0` == "zless" ] ; then
1.7       zhuk       43:        pager=less
1.5       jsg        44: else
1.7       zhuk       45:        pager=more
1.5       jsg        46: fi
                     47:
1.2       millert    48: # No files means read from stdin
1.1       millert    49: if [ $# -eq 0 ]; then
1.6       mpf        50:        compress -cdf 2>&1 | $pager $flags
1.2       millert    51:        exit 0
1.1       millert    52: fi
                     53:
                     54: oterm=`stty -g 2>/dev/null`
                     55: while test $# -ne 0; do
1.6       mpf        56:        compress -cdf "$1" 2>&1 | $pager $flags
1.1       millert    57:        prev="$1"
                     58:        shift
1.2       millert    59:        if tty -s && test -n "$oterm" -a $# -gt 0; then
                     60:                #echo -n "--More--(Next file: $1)"
                     61:                echo -n "$prev (END) - Next: $1 "
                     62:                trap "stty $oterm 2>/dev/null" 0 1 2 3 13 15
                     63:                stty cbreak -echo 2>/dev/null
                     64:                REPLY=`dd bs=1 count=1 2>/dev/null`
                     65:                stty $oterm 2>/dev/null
                     66:                trap - 0 1 2 3 13 15
                     67:                echo
                     68:                case "$REPLY" in
                     69:                        s)
                     70:                                shift
                     71:                                ;;
                     72:                        e|q)
                     73:                                break
                     74:                                ;;
                     75:                esac
                     76:        fi
1.1       millert    77: done
                     78: exit 0