summaryrefslogtreecommitdiffstats
path: root/usr.bin/tar
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2004-08-27 04:13:15 +0000
committerkientzle <kientzle@FreeBSD.org>2004-08-27 04:13:15 +0000
commit2e9ab3a6f5ed5d3374c66e277633317c1b45482c (patch)
treed932cb9d15ea6090eed7c29ffcc5dd76271a8e85 /usr.bin/tar
parent09461d1cd48691596892d930b4e7291a2f8b67d9 (diff)
downloadFreeBSD-src-2e9ab3a6f5ed5d3374c66e277633317c1b45482c.zip
FreeBSD-src-2e9ab3a6f5ed5d3374c66e277633317c1b45482c.tar.gz
Support -t -O as in gtar. Perversely enough, -O means "send to stderr"
when used with -t, "send to stdout" when used with -x. Thanks to: Ryan Hamilton for pointing out this odd beast MFC after: 3 days
Diffstat (limited to 'usr.bin/tar')
-rw-r--r--usr.bin/tar/bsdtar.c2
-rw-r--r--usr.bin/tar/read.c25
2 files changed, 16 insertions, 11 deletions
diff --git a/usr.bin/tar/bsdtar.c b/usr.bin/tar/bsdtar.c
index cb8244f..52d7bf8 100644
--- a/usr.bin/tar/bsdtar.c
+++ b/usr.bin/tar/bsdtar.c
@@ -481,7 +481,7 @@ main(int argc, char **argv)
if (bsdtar->option_no_subdirs)
only_mode(bsdtar, "-n", "cru");
if (bsdtar->option_stdout)
- only_mode(bsdtar, "-O", "x");
+ only_mode(bsdtar, "-O", "xt");
if (bsdtar->option_warn_links)
only_mode(bsdtar, "--check-links", "cr");
diff --git a/usr.bin/tar/read.c b/usr.bin/tar/read.c
index 11eb644..79d8faf 100644
--- a/usr.bin/tar/read.c
+++ b/usr.bin/tar/read.c
@@ -46,7 +46,8 @@ __FBSDID("$FreeBSD$");
#include "bsdtar.h"
static void cleanup_security(struct bsdtar *);
-static void list_item_verbose(struct bsdtar *, struct archive_entry *);
+static void list_item_verbose(struct bsdtar *, FILE *,
+ struct archive_entry *);
static void read_archive(struct bsdtar *bsdtar, char mode);
static int security_problem(struct bsdtar *, struct archive_entry *);
@@ -68,6 +69,7 @@ tar_mode_x(struct bsdtar *bsdtar)
static void
read_archive(struct bsdtar *bsdtar, char mode)
{
+ FILE *out;
struct archive *a;
struct archive_entry *entry;
int r;
@@ -117,30 +119,34 @@ read_archive(struct bsdtar *bsdtar, char mode)
continue;
if (mode == 't') {
+ /* Perversely, gtar uses -O to mean "send to stderr"
+ * when used with -t. */
+ out = bsdtar->option_stdout ? stderr : stdout;
+
if (bsdtar->verbose < 2)
- safe_fprintf(stdout, "%s",
+ safe_fprintf(out, "%s",
archive_entry_pathname(entry));
else
- list_item_verbose(bsdtar, entry);
- fflush(stdout);
+ list_item_verbose(bsdtar, out, entry);
+ fflush(out);
r = archive_read_data_skip(a);
if (r == ARCHIVE_WARN) {
- fprintf(stdout, "\n");
+ fprintf(out, "\n");
bsdtar_warnc(bsdtar, 0, "%s",
archive_error_string(a));
}
if (r == ARCHIVE_RETRY) {
- fprintf(stdout, "\n");
+ fprintf(out, "\n");
bsdtar_warnc(bsdtar, 0, "%s",
archive_error_string(a));
}
if (r == ARCHIVE_FATAL) {
- fprintf(stdout, "\n");
+ fprintf(out, "\n");
bsdtar_warnc(bsdtar, 0, "%s",
archive_error_string(a));
break;
}
- fprintf(stdout, "\n");
+ fprintf(out, "\n");
} else {
if (bsdtar->option_interactive &&
!yes("extract '%s'", archive_entry_pathname(entry)))
@@ -199,9 +205,8 @@ read_archive(struct bsdtar *bsdtar, char mode)
* and 'pax -l' is documented as using the same format as 'ls -l'.
*/
static void
-list_item_verbose(struct bsdtar *bsdtar, struct archive_entry *entry)
+list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry)
{
- FILE *out = stdout;
const struct stat *st;
char tmp[100];
size_t w;
OpenPOWER on IntegriCloud