From owner-svn-src-all@FreeBSD.ORG Thu Oct 21 17:05:16 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2DEE6106566C; Thu, 21 Oct 2010 17:05:16 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1D8668FC17; Thu, 21 Oct 2010 17:05:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9LH5Gva097262; Thu, 21 Oct 2010 17:05:16 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9LH5GH5097260; Thu, 21 Oct 2010 17:05:16 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201010211705.o9LH5GH5097260@svn.freebsd.org> From: Gleb Smirnoff Date: Thu, 21 Oct 2010 17:05:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214137 - head/usr.bin/unzip X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Oct 2010 17:05:16 -0000 Author: glebius Date: Thu Oct 21 17:05:15 2010 New Revision: 214137 URL: http://svn.freebsd.org/changeset/base/214137 Log: Make it possible to read input from stdin. Without this change I don't see a way to unpack a multivolume archive without wasting disk space for a temporary file. Modified: head/usr.bin/unzip/unzip.c Modified: head/usr.bin/unzip/unzip.c ============================================================================== --- head/usr.bin/unzip/unzip.c Thu Oct 21 16:20:48 2010 (r214136) +++ head/usr.bin/unzip/unzip.c Thu Oct 21 17:05:15 2010 (r214137) @@ -859,7 +859,9 @@ unzip(const char *fn) int fd, ret; uintmax_t total_size, file_count, error_count; - if ((fd = open(fn, O_RDONLY)) < 0) + if (strcmp(fn, "-") == 0) + fd = STDIN_FILENO; + else if ((fd = open(fn, O_RDONLY)) < 0) error("%s", fn); if ((a = archive_read_new()) == NULL) @@ -913,7 +915,7 @@ unzip(const char *fn) ac(archive_read_close(a)); (void)archive_read_finish(a); - if (close(fd) != 0) + if (fd != STDIN_FILENO && close(fd) != 0) error("%s", fn); if (t_opt) {