aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-01-20 22:29:25 -0600
committerRob Landley <rob@landley.net>2018-01-20 22:29:25 -0600
commitb76343c9d970e1ae1935c4f629bd4c24dd531b40 (patch)
tree8826b3e0b2e7fd46bbd2ae05c738c19cc0794f9f
parent416397e14858c75a9bf20d05f7729595e03943df (diff)
downloadtoybox-b76343c9d970e1ae1935c4f629bd4c24dd531b40.tar.gz
Fix gunzip to past test_gunzip.
-rw-r--r--toys/pending/gzip.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/toys/pending/gzip.c b/toys/pending/gzip.c
index 894a2914..72e8fe4c 100644
--- a/toys/pending/gzip.c
+++ b/toys/pending/gzip.c
@@ -102,7 +102,7 @@ static void do_gunzip(int in_fd, char *arg)
int len, out_fd = 0;
char *out_name = 0;
- // Are we writing to stderr?
+ // Are we writing to stdout?
if (!in_fd || (toys.optflags&FLAG_c)) out_fd = 1;
if (isatty(in_fd)) {
if (!(toys.optflags&FLAG_f)) {
@@ -118,7 +118,7 @@ static void do_gunzip(int in_fd, char *arg)
error_msg("no .gz: %s", arg);
return;
}
- if (!stat(arg, &sb)) {
+ if (fstat(in_fd, &sb)) {
perror_msg("%s", arg);
return;
}
@@ -130,9 +130,9 @@ static void do_gunzip(int in_fd, char *arg)
if (out_fd == -1) return;
}
- if (CFG_TOYBOX_LIBZ)
+// if (CFG_TOYBOX_LIBZ)
if (zlib_inflate(in_fd, out_fd) && out_name) arg = out_name;
- close(out_fd);
+ if (out_fd != 1) close(out_fd);
if (out_name) {
fix_time(out_name, &sb);