aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTim Kientzle <kientzle@FreeBSD.org>2008-08-21 06:41:14 +0000
committerTim Kientzle <kientzle@FreeBSD.org>2008-08-21 06:41:14 +0000
commite0e53b4111f9fb84f5c3d74bcf7cfe4758380a2a (patch)
treedae933b69a6acf10237a98016c4abe0d112f8937 /usr.bin
parent96ee09c546af628bd3c8db85134e91a603f91eba (diff)
downloadsrc-e0e53b4111f9fb84f5c3d74bcf7cfe4758380a2a.tar.gz
src-e0e53b4111f9fb84f5c3d74bcf7cfe4758380a2a.zip
Always display the unedited pathname in -t output.
I would like to provide a way to preview the effects of pathname edits, but pattern selection has to happen against the unedited path, so it seems that we have to show people the unedited path to help in designing selection patterns.
Notes
Notes: svn path=/head/; revision=181958
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tar/read.c21
-rw-r--r--usr.bin/tar/test/test_patterns.c4
-rw-r--r--usr.bin/tar/test/test_patterns_2.tgz.err.uu6
-rw-r--r--usr.bin/tar/test/test_patterns_2.tgz.out.uu2
4 files changed, 12 insertions, 21 deletions
diff --git a/usr.bin/tar/read.c b/usr.bin/tar/read.c
index c66106093e1a..35cea89a95a2 100644
--- a/usr.bin/tar/read.c
+++ b/usr.bin/tar/read.c
@@ -210,22 +210,17 @@ read_archive(struct bsdtar *bsdtar, char mode)
if (excluded(bsdtar, archive_entry_pathname(entry)))
continue; /* Excluded by a pattern test. */
- /*
- * Modify the pathname as requested by the user. We
- * do this for -t as well to give users a way to
- * preview the effects of their rewrites. We also do
- * this before extraction security checks (including
- * leading '/' removal). Note that some rewrite
- * failures prevent extraction.
- */
- if (edit_pathname(bsdtar, entry))
- continue; /* Excluded by a rewrite failure. */
-
if (mode == 't') {
/* Perversely, gtar uses -O to mean "send to stderr"
* when used with -t. */
out = bsdtar->option_stdout ? stderr : stdout;
+ /*
+ * TODO: Provide some reasonable way to
+ * preview rewrites. gtar always displays
+ * the unedited path in -t output, which means
+ * you cannot easily preview rewrites.
+ */
if (bsdtar->verbose < 2)
safe_fprintf(out, "%s",
archive_entry_pathname(entry));
@@ -252,6 +247,10 @@ read_archive(struct bsdtar *bsdtar, char mode)
}
fprintf(out, "\n");
} else {
+ /* Note: some rewrite failures prevent extraction. */
+ if (edit_pathname(bsdtar, entry))
+ continue; /* Excluded by a rewrite failure. */
+
if (bsdtar->option_interactive &&
!yes("extract '%s'", archive_entry_pathname(entry)))
continue;
diff --git a/usr.bin/tar/test/test_patterns.c b/usr.bin/tar/test/test_patterns.c
index a90d711039ce..575e8a411232 100644
--- a/usr.bin/tar/test/test_patterns.c
+++ b/usr.bin/tar/test/test_patterns.c
@@ -30,7 +30,6 @@ DEFINE_TEST(test_patterns)
int fd, r;
const char *reffile2 = "test_patterns_2.tgz";
const char *reffile2_out = "test_patterns_2.tgz.out";
- const char *reffile2_err = "test_patterns_2.tgz.err";
/*
* Test basic command-line pattern handling.
@@ -56,13 +55,12 @@ DEFINE_TEST(test_patterns)
*/
extract_reference_file(reffile2);
extract_reference_file(reffile2_out);
- extract_reference_file(reffile2_err);
r = systemf("%s tf %s /tmp/foo/bar > tar2a.out 2> tar2a.err",
testprog, reffile2);
assertEqualInt(r, 0);
assertEqualFile("tar2a.out", reffile2_out);
- assertEqualFile("tar2a.err", reffile2_err);
+ assertEmptyFile("tar2a.err");
/*
*
diff --git a/usr.bin/tar/test/test_patterns_2.tgz.err.uu b/usr.bin/tar/test/test_patterns_2.tgz.err.uu
deleted file mode 100644
index cb0593087d31..000000000000
--- a/usr.bin/tar/test/test_patterns_2.tgz.err.uu
+++ /dev/null
@@ -1,6 +0,0 @@
-$FreeBSD$
-begin 644 test_patterns_2.tgz.err
-M8G-D=&%R.B!296UO=FEN9R!L96%D:6YG("<O)R!F<F]M(&UE;6)E<B!N86UE
-"<PH`
-`
-end
diff --git a/usr.bin/tar/test/test_patterns_2.tgz.out.uu b/usr.bin/tar/test/test_patterns_2.tgz.out.uu
index f2de5fbf6a27..1c7f09278133 100644
--- a/usr.bin/tar/test/test_patterns_2.tgz.out.uu
+++ b/usr.bin/tar/test/test_patterns_2.tgz.out.uu
@@ -1,5 +1,5 @@
$FreeBSD$
begin 644 test_patterns_2.tgz.out
-==&UP+V9O;R]B87(O"G1M<"]F;V\O8F%R+V)A>@H`
+?+W1M<"]F;V\O8F%R+PHO=&UP+V9O;R]B87(O8F%Z"@``
`
end