1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-06 13:09:50 +00:00

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.
This commit is contained in:
Tim Kientzle 2008-08-21 06:41:14 +00:00
parent 96ee09c546
commit e0e53b4111
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=181958
4 changed files with 12 additions and 21 deletions

View File

@ -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;

View File

@ -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");
/*
*

View File

@ -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

View File

@ -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