diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-06-23 19:04:25 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-06-23 19:04:25 +0000 |
commit | 4e22c3b1b31fc4dd225bc22d0e16133481add6fe (patch) | |
tree | 10d712df0f6d7131eabf95774f9daaa9ddfa128e /usr.bin | |
parent | 28f3c3e5c954c2a9045002b84dff2c0a67167d7b (diff) |
Make zmore read from stdin when no files are specified and try to
ascertain wether or not we have a tty. Also add a skeleton manual page.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/compress/zmore | 43 | ||||
-rw-r--r-- | usr.bin/compress/zmore.1 | 91 |
2 files changed, 114 insertions, 20 deletions
diff --git a/usr.bin/compress/zmore b/usr.bin/compress/zmore index 7066a663929..0f21517de69 100644 --- a/usr.bin/compress/zmore +++ b/usr.bin/compress/zmore @@ -37,32 +37,35 @@ while test $# -ne 0; do esac done +# No files means read from stdin +# XXX - cannot distinguish between gzip or compress, assume gzip if [ $# -eq 0 ]; then - echo "usage: zmore filename ..." - exit 1 + compress -cdfgq 2>&1 | ${PAGER-more} $flags + exit 0 fi oterm=`stty -g 2>/dev/null` while test $# -ne 0; do - gzip -cdfq "$1" 2>&1 | ${PAGER-more} $flags + compress -cdfq "$1" 2>&1 | ${PAGER-more} $flags prev="$1" shift - test $# -eq 0 && break - #echo -n "--More--(Next file: $1)" - echo -n "$prev (END) - Next: $1 " - trap "stty $oterm 2>/dev/null" 0 1 2 3 13 15 - stty cbreak -echo 2>/dev/null - REPLY=`dd bs=1 count=1 2>/dev/null` - stty $oterm 2>/dev/null - trap - 0 1 2 3 13 15 - echo - case "$REPLY" in - s) - shift - ;; - e|q) - break - ;; - esac + if tty -s && test -n "$oterm" -a $# -gt 0; then + #echo -n "--More--(Next file: $1)" + echo -n "$prev (END) - Next: $1 " + trap "stty $oterm 2>/dev/null" 0 1 2 3 13 15 + stty cbreak -echo 2>/dev/null + REPLY=`dd bs=1 count=1 2>/dev/null` + stty $oterm 2>/dev/null + trap - 0 1 2 3 13 15 + echo + case "$REPLY" in + s) + shift + ;; + e|q) + break + ;; + esac + fi done exit 0 diff --git a/usr.bin/compress/zmore.1 b/usr.bin/compress/zmore.1 new file mode 100644 index 00000000000..b327014ed82 --- /dev/null +++ b/usr.bin/compress/zmore.1 @@ -0,0 +1,91 @@ +.\" $OpenBSD: zmore.1,v 1.1 2003/06/23 19:04:24 millert Exp $ +.\" +.\" Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com> +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.\" Sponsored in part by the Defense Advanced Research Projects +.\" Agency (DARPA) and Air Force Research Laboratory, Air Force +.\" Materiel Command, USAF, under agreement number F39502-99-1-0512. +.\" +.Dd June 23, 2003 +.Dt ZMORE 1 +.Os +.Sh NAME +.Nm zmore +.Nd view compressed files on a crt +.Sh SYNOPSIS +.Nm zmore +.Op Ar flags +.Op Ar file ... +.Sh DESCRIPTION +.Nm +is a filter that allows the viewing of files compressed with Lempel-Ziv +encoding. +Such files generally have a +.Dq Z +or +.Dq gz +extension (both the +.Xr compress 1 +and +.Xr gzip 1 +formats are supported). +Any +.Ar flags +that are specified are passed to the user's preferred +.Ev PAGER +.No ( Ns Pa /usr/bin/more +by default). +.Pp +When multiple files are specified, +.Nm +will pause at the end of each file and present the following prompt to the user: +.Bd -literal -offset indent +prev_file (END) - Next: next_file +.Ed +.Pp +Where +.Sy prev_file +is the file that was just displayed and +.Sy next_file +is the next file to be displayed. +The following keys are recognized at the prompt: +.Bl -tag -width "e or q" -offset indent +.It e or q +quit +.Nm zmore . +.It s +skip the next file (or exit if the next file is the last). +.El +.Pp +If no files are specified, +.Nm +will read from the standard input. +In this mode +.Nm +will assume +.Xr gzip 1 +style compression since there is no suffix on which to make a decision. +.Sh ENVIRONMENT +.Bl -tag -width "PAGER" +.It Ev PAGER +Program used to display files. +If unset, +.Pa /usr/bin/more +is used. +.El +.Sh SEE ALSO +.Xr more 1 , +.Xr less 1 , +.Xr compress 1 |