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

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

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