diff options
author | Eric Andersen | 2001-06-21 19:30:10 +0000 |
---|---|---|
committer | Eric Andersen | 2001-06-21 19:30:10 +0000 |
commit | 091781e20eb055ac286b5a617d53a50c7d6c451e (patch) | |
tree | 2be329d957ce48547b950cc1c56d14d32096b055 /archival | |
parent | 8a646dd2933bc37e67e1b09fd3461816e38fc677 (diff) | |
download | busybox-091781e20eb055ac286b5a617d53a50c7d6c451e.zip busybox-091781e20eb055ac286b5a617d53a50c7d6c451e.tar.gz |
Support tar -C, per bug #1176
-Erik
Diffstat (limited to 'archival')
-rw-r--r-- | archival/tar.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/archival/tar.c b/archival/tar.c index 8dec434..55fb12c 100644 --- a/archival/tar.c +++ b/archival/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 |