From dc8454644141370b952eee38f3e9dc938f5f20fe Mon Sep 17 00:00:00 2001 From: tjr Date: Fri, 17 May 2002 01:42:43 +0000 Subject: As required by SUSv3, a file argument of "-" causes standard input to be compressed/decompressed to standard output. --- usr.bin/compress/compress.1 | 7 +++++-- usr.bin/compress/compress.c | 9 ++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'usr.bin/compress') diff --git a/usr.bin/compress/compress.1 b/usr.bin/compress/compress.1 index cb69bcb..b8a12e5 100644 --- a/usr.bin/compress/compress.1 +++ b/usr.bin/compress/compress.1 @@ -79,8 +79,11 @@ output) for confirmation. If prompting is not possible or confirmation is not received, the files are not overwritten. .Pp -If no files are specified, the standard input is compressed or uncompressed -to the standard output. +If no files are specified or a +.Ar file +argument is a single dash +.Pq Ql - , +the standard input is compressed or uncompressed to the standard output. If either the input and output files are not regular files, the checks for reduction in size and file overwriting are not performed, the input file is not removed, and the attributes of the input file are not retained. diff --git a/usr.bin/compress/compress.c b/usr.bin/compress/compress.c index 866e187..f7d1373 100644 --- a/usr.bin/compress/compress.c +++ b/usr.bin/compress/compress.c @@ -140,7 +140,10 @@ main(argc, argv) for (; *argv; ++argv) switch(style) { case COMPRESS: - if (cat) { + if (strcmp(*argv, "-") == 0) { + compress("/dev/stdin", "/dev/stdout", bits); + break; + } else if (cat) { compress(*argv, "/dev/stdout", bits); break; } @@ -162,6 +165,10 @@ main(argc, argv) compress(*argv, newname, bits); break; case DECOMPRESS: + if (strcmp(*argv, "-") == 0) { + decompress("/dev/stdin", "/dev/stdout", bits); + break; + } len = strlen(*argv); if ((p = rindex(*argv, '.')) == NULL || strcmp(p, ".Z")) { -- cgit v1.1