]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Support "-" (stdio) for the TAPE environment variable.
authorTim Kientzle <kientzle@gmail.com>
Mon, 1 Feb 2010 02:56:52 +0000 (21:56 -0500)
committerTim Kientzle <kientzle@gmail.com>
Mon, 1 Feb 2010 02:56:52 +0000 (21:56 -0500)
On MacOS, set "-" as the default device, since there is no tape support.

SVN-Revision: 1848

tar/bsdtar.c

index d8f8286842e9cb4aa996a4471295b35e4695783e..39ff453be6370a67f71efaddf71ec9c1bc68f123 100644 (file)
@@ -80,6 +80,9 @@ __FBSDID("$FreeBSD: src/usr.bin/tar/bsdtar.c,v 1.93 2008/11/08 04:43:24 kientzle
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #define        _PATH_DEFTAPE "\\\\.\\tape0"
 #endif
+#if defined(__APPLE__)
+#define _PATH_DEFTAPE "-"  /* Mac OS has no tape support, default to stdio. */
+#endif
 
 #ifndef _PATH_DEFTAPE
 #define        _PATH_DEFTAPE "/dev/tape"
@@ -268,8 +271,6 @@ main(int argc, char **argv)
                        break;
                case 'f': /* SUSv2 */
                        bsdtar->filename = bsdtar->optarg;
-                       if (strcmp(bsdtar->filename, "-") == 0)
-                               bsdtar->filename = NULL;
                        break;
                case 'H': /* BSD convention */
                        bsdtar->symlink_mode = 'H';
@@ -597,6 +598,10 @@ main(int argc, char **argv)
        if (bsdtar->strip_components != 0)
                only_mode(bsdtar, "--strip-components", "xt");
 
+       /* Filename "-" implies stdio. */
+       if (strcmp(bsdtar->filename, "-") == 0)
+               bsdtar->filename = NULL;
+
        switch(bsdtar->mode) {
        case 'c':
                tar_mode_c(bsdtar);