aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/gzip.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/pending/gzip.c')
-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);