diff options
author | czarkoff <czarkoff@cvs.openbsd.org> | 2015-05-18 20:26:17 +0000 |
---|---|---|
committer | czarkoff <czarkoff@cvs.openbsd.org> | 2015-05-18 20:26:17 +0000 |
commit | 4f6ab9552a3d10318a30f27d546804104f04dbac (patch) | |
tree | 75d5e97e38119709d13ad51d6e6fdeb3732d292a /bin | |
parent | 9dc5e46addfc822d5937923bf22f8c06bab6c5b5 (diff) |
Make TAPE=- mean stdout in tar
Some scripts and GUI ssh clients assume that tar writes to standard output by
default. This changes allows enforcing such behavior by setting TAPE="-" in
user profile.
Also, this makes parsing argument to "-f" option and contents of TAPE
environment variable consistent.
OK guenther@, jmc@ and sthen@
Diffstat (limited to 'bin')
-rw-r--r-- | bin/pax/options.c | 17 | ||||
-rw-r--r-- | bin/pax/tar.1 | 13 |
2 files changed, 22 insertions, 8 deletions
diff --git a/bin/pax/options.c b/bin/pax/options.c index be2ffb2c245..2b15d395203 100644 --- a/bin/pax/options.c +++ b/bin/pax/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.90 2015/04/18 18:28:37 deraadt Exp $ */ +/* $OpenBSD: options.c,v 1.91 2015/05/18 20:26:16 czarkoff Exp $ */ /* $NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $ */ /*- @@ -877,6 +877,16 @@ tar_options(int argc, char **argv) argc -= optind; argv += optind; + if (!fstdin && ((arcname == NULL) || (*arcname == '\0'))) { + arcname = getenv("TAPE"); + if ((arcname == NULL) || (*arcname == '\0')) + arcname = _PATH_DEFTAPE; + else if ((arcname[0] == '-') && (arcname[1]== '\0')) { + arcname = NULL; + fstdin = 1; + } + } + /* Traditional tar behaviour (pax uses stderr unless in list mode) */ if (fstdin == 1 && act == ARCHIVE) listf = stderr; @@ -1030,11 +1040,6 @@ tar_options(int argc, char **argv) maxflt = 0; break; } - if (!fstdin && ((arcname == NULL) || (*arcname == '\0'))) { - arcname = getenv("TAPE"); - if ((arcname == NULL) || (*arcname == '\0')) - arcname = _PATH_DEFTAPE; - } } int mkpath(char *); diff --git a/bin/pax/tar.1 b/bin/pax/tar.1 index c4c10834f88..ba487d4233f 100644 --- a/bin/pax/tar.1 +++ b/bin/pax/tar.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tar.1,v 1.57 2015/01/15 19:06:31 schwarze Exp $ +.\" $OpenBSD: tar.1,v 1.58 2015/05/18 20:26:16 czarkoff Exp $ .\" .\" Copyright (c) 1996 SigmaSoft, Th. Lockert .\" All rights reserved. @@ -23,7 +23,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: January 15 2015 $ +.Dd $Mdocdate: May 18 2015 $ .Dt TAR 1 .Os .Sh NAME @@ -145,6 +145,12 @@ Stop after the first error. Filename where the archive is stored. Defaults to .Pa /dev/rst0 . +If set to hyphen +.Pq Sq - +standard output is used. +See also the +.Ev TAPE +environment variable. .It Fl H Follow symlinks given on the command line only. .It Fl h @@ -287,6 +293,9 @@ Path in which to store temporary files. .It Ev TAPE Default tape device to use instead of .Pa /dev/rst0 . +If set to hyphen +.Pq Sq - +standard output is used. .El .Sh FILES .Bl -tag -width "/dev/rst0" |