diff options
author | kientzle <kientzle@FreeBSD.org> | 2008-08-21 06:41:14 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2008-08-21 06:41:14 +0000 |
commit | b25650cc125c051999d50e3520607fe1e1139297 (patch) | |
tree | dae933b69a6acf10237a98016c4abe0d112f8937 /usr.bin | |
parent | d65180d188d8101c7b81876ea47716931050c00a (diff) | |
download | FreeBSD-src-b25650cc125c051999d50e3520607fe1e1139297.zip FreeBSD-src-b25650cc125c051999d50e3520607fe1e1139297.tar.gz |
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.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tar/read.c | 21 | ||||
-rw-r--r-- | usr.bin/tar/test/test_patterns.c | 4 | ||||
-rw-r--r-- | usr.bin/tar/test/test_patterns_2.tgz.err.uu | 6 | ||||
-rw-r--r-- | usr.bin/tar/test/test_patterns_2.tgz.out.uu | 2 |
4 files changed, 12 insertions, 21 deletions
diff --git a/usr.bin/tar/read.c b/usr.bin/tar/read.c index c661060..35cea89 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 a90d711..575e8a4 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 cb05930..0000000 --- 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 f2de5fb..1c7f092 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 |