summaryrefslogtreecommitdiffstats
path: root/usr.bin/tar
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2004-07-17 04:17:50 +0000
committerkientzle <kientzle@FreeBSD.org>2004-07-17 04:17:50 +0000
commit7f77b9d9fb88afc0949c3855c9c66ffc35512490 (patch)
tree6a783750607d4e57db70a54aa149577f9ca0f720 /usr.bin/tar
parente867ac8953c362a486c040fc45376ad7cc294fc7 (diff)
downloadFreeBSD-src-7f77b9d9fb88afc0949c3855c9c66ffc35512490.zip
FreeBSD-src-7f77b9d9fb88afc0949c3855c9c66ffc35512490.tar.gz
Validate -o usage. Strictly speaking, -o only makes sense with -x,
of course, but I make an effort to accomodate GNU tar scripts that use -o with -c (with a meaning that totally contradicts SUSv2) by only issuing a benign warning message in that case.
Diffstat (limited to 'usr.bin/tar')
-rw-r--r--usr.bin/tar/bsdtar.c7
-rw-r--r--usr.bin/tar/bsdtar.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/usr.bin/tar/bsdtar.c b/usr.bin/tar/bsdtar.c
index d822851..aad2ba2 100644
--- a/usr.bin/tar/bsdtar.c
+++ b/usr.bin/tar/bsdtar.c
@@ -293,6 +293,7 @@ main(int argc, char **argv)
bsdtar->option_stdout = 1;
break;
case 'o': /* SUSv2; note that GNU -o conflicts */
+ bsdtar->option_no_owner = 1;
bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_OWNER;
break;
case OPTION_ONE_FILE_SYSTEM: /* -l in GNU tar */
@@ -409,6 +410,12 @@ main(int argc, char **argv)
only_mode(bsdtar, mode, "--fast-read", "xt");
if (bsdtar->option_honor_nodump)
only_mode(bsdtar, mode, "--nodump", "cru");
+ if (bsdtar->option_no_owner) {
+ only_mode(bsdtar, mode, "-o", "xc");
+ /* Warn about nonsensical -co combination, but ignore it. */
+ if (mode == 'c')
+ bsdtar_warnc(bsdtar, 0, "-o is incompatible with -c");
+ }
if (bsdtar->option_no_subdirs)
only_mode(bsdtar, mode, "-n", "cru");
if (bsdtar->option_stdout)
diff --git a/usr.bin/tar/bsdtar.h b/usr.bin/tar/bsdtar.h
index e4c1761..712a47d 100644
--- a/usr.bin/tar/bsdtar.h
+++ b/usr.bin/tar/bsdtar.h
@@ -58,6 +58,7 @@ struct bsdtar {
char option_fast_read; /* --fast-read */
char option_honor_nodump; /* --nodump */
char option_interactive; /* -w */
+ char option_no_owner; /* -o */
char option_no_subdirs; /* -d */
char option_null; /* --null */
char option_stdout; /* -p */
OpenPOWER on IntegriCloud