From b3ea6ecd42651a025765798fc7886e03d5dcd6cb Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sat, 17 Jul 2004 04:17:50 +0000 Subject: [PATCH] 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. --- usr.bin/tar/bsdtar.c | 7 +++++++ usr.bin/tar/bsdtar.h | 1 + 2 files changed, 8 insertions(+) diff --git a/usr.bin/tar/bsdtar.c b/usr.bin/tar/bsdtar.c index d822851970c4..aad2ba2688dd 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 e4c1761929fa..712a47de7fc8 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 */