aboutsummaryrefslogtreecommitdiff
path: root/tar.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-06-21 19:30:10 +0000
committerEric Andersen <andersen@codepoet.org>2001-06-21 19:30:10 +0000
commit091781e20eb055ac286b5a617d53a50c7d6c451e (patch)
tree2be329d957ce48547b950cc1c56d14d32096b055 /tar.c
parent8a646dd2933bc37e67e1b09fd3461816e38fc677 (diff)
downloadbusybox-091781e20eb055ac286b5a617d53a50c7d6c451e.tar.gz
Support tar -C, per bug #1176
-Erik
Diffstat (limited to 'tar.c')
-rw-r--r--tar.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/tar.c b/tar.c
index 8dec4349d..55fb12c2c 100644
--- a/tar.c
+++ b/tar.c
@@ -151,6 +151,7 @@ extern int tar_main(int argc, char **argv)
char** excludeList=NULL;
char** extractList=NULL;
const char *tarName="-";
+ const char *cwd=NULL;
#if defined BB_FEATURE_TAR_EXCLUDE
int excludeListSize=0;
FILE *fileList;
@@ -181,9 +182,9 @@ extern int tar_main(int argc, char **argv)
while (
#ifndef BB_FEATURE_TAR_EXCLUDE
- (opt = getopt(argc, argv, "cxtzvOf:p"))
+ (opt = getopt(argc, argv, "cxtzvOf:pC:"))
#else
- (opt = getopt_long(argc, argv, "cxtzvOf:X:p", longopts, NULL))
+ (opt = getopt_long(argc, argv, "cxtzvOf:X:pC:", longopts, NULL))
#endif
> 0) {
switch (opt) {
@@ -240,6 +241,13 @@ extern int tar_main(int argc, char **argv)
#endif
case 'p':
break;
+ case 'C':
+ cwd = xgetcwd((char *)cwd);
+ if (chdir(optarg)) {
+ printf("cd: %s: %s\n", optarg, strerror(errno));
+ return EXIT_FAILURE;
+ }
+ break;
default:
show_usage();
}
@@ -292,6 +300,8 @@ extern int tar_main(int argc, char **argv)
#endif
}
+ if (cwd)
+ chdir(cwd);
if (status == TRUE)
return EXIT_SUCCESS;
else