aboutsummaryrefslogtreecommitdiff
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
parent8a646dd2933bc37e67e1b09fd3461816e38fc677 (diff)
downloadbusybox-w32-091781e20eb055ac286b5a617d53a50c7d6c451e.tar.gz
busybox-w32-091781e20eb055ac286b5a617d53a50c7d6c451e.tar.bz2
busybox-w32-091781e20eb055ac286b5a617d53a50c7d6c451e.zip
Support tar -C, per bug #1176
-Erik
-rw-r--r--applets/usage.h11
-rw-r--r--archival/tar.c14
-rw-r--r--include/usage.h11
-rw-r--r--tar.c14
-rw-r--r--usage.h11
5 files changed, 42 insertions, 19 deletions
diff --git a/applets/usage.h b/applets/usage.h
index d68652fe5..acba3677c 100644
--- a/applets/usage.h
+++ b/applets/usage.h
@@ -1154,9 +1154,10 @@
1154 "221 foobar closing connection\n" 1154 "221 foobar closing connection\n"
1155 1155
1156#define nslookup_trivial_usage \ 1156#define nslookup_trivial_usage \
1157 "[HOST]" 1157 "[HOST] [SERVER]"
1158#define nslookup_full_usage \ 1158#define nslookup_full_usage \
1159 "Queries the nameserver for the IP address of the given HOST" 1159 "Queries the nameserver for the IP address of the given HOST\n" \
1160 "optionally using a specified DNS server"
1160#define nslookup_example_usage \ 1161#define nslookup_example_usage \
1161 "$ nslookup localhost\n" \ 1162 "$ nslookup localhost\n" \
1162 "Server: default\n" \ 1163 "Server: default\n" \
@@ -1469,10 +1470,10 @@
1469#define tar_trivial_usage \ 1470#define tar_trivial_usage \
1470 "-[" USAGE_TAR_CREATE("c") "xtvO] " \ 1471 "-[" USAGE_TAR_CREATE("c") "xtvO] " \
1471 USAGE_TAR_EXCLUDE("[--exclude FILE] [-X FILE]") \ 1472 USAGE_TAR_EXCLUDE("[--exclude FILE] [-X FILE]") \
1472 "[-f TARFILE] [FILE(s)] ..." 1473 "[-f TARFILE] [-C DIR] [FILE(s)] ..."
1473#define tar_full_usage \ 1474#define tar_full_usage \
1474 "Create, extract, or list files from a tar file.\n\n" \ 1475 "Create, extract, or list files from a tar file.\n\n" \
1475 "Main operation mode:\n" \ 1476 "Options:\n" \
1476 USAGE_TAR_CREATE("\tc\t\tcreate\n") \ 1477 USAGE_TAR_CREATE("\tc\t\tcreate\n") \
1477 "\tx\t\textract\n" \ 1478 "\tx\t\textract\n" \
1478 "\tt\t\tlist\n" \ 1479 "\tt\t\tlist\n" \
@@ -1483,7 +1484,7 @@
1483 "\texclude\t\tfile to exclude\n" \ 1484 "\texclude\t\tfile to exclude\n" \
1484 "\tX\t\tfile with names to exclude\n" \ 1485 "\tX\t\tfile with names to exclude\n" \
1485 ) \ 1486 ) \
1486 "\nInformative output:\n" \ 1487 "\tC\t\tchange to directory DIR before operation\n" \
1487 "\tv\t\tverbosely list files processed" 1488 "\tv\t\tverbosely list files processed"
1488#define tar_example_usage \ 1489#define tar_example_usage \
1489 "$ zcat /tmp/tarball.tar.gz | tar -xf -\n" \ 1490 "$ zcat /tmp/tarball.tar.gz | tar -xf -\n" \
diff --git a/archival/tar.c b/archival/tar.c
index 8dec4349d..55fb12c2c 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -151,6 +151,7 @@ extern int tar_main(int argc, char **argv)
151 char** excludeList=NULL; 151 char** excludeList=NULL;
152 char** extractList=NULL; 152 char** extractList=NULL;
153 const char *tarName="-"; 153 const char *tarName="-";
154 const char *cwd=NULL;
154#if defined BB_FEATURE_TAR_EXCLUDE 155#if defined BB_FEATURE_TAR_EXCLUDE
155 int excludeListSize=0; 156 int excludeListSize=0;
156 FILE *fileList; 157 FILE *fileList;
@@ -181,9 +182,9 @@ extern int tar_main(int argc, char **argv)
181 182
182 while ( 183 while (
183#ifndef BB_FEATURE_TAR_EXCLUDE 184#ifndef BB_FEATURE_TAR_EXCLUDE
184 (opt = getopt(argc, argv, "cxtzvOf:p")) 185 (opt = getopt(argc, argv, "cxtzvOf:pC:"))
185#else 186#else
186 (opt = getopt_long(argc, argv, "cxtzvOf:X:p", longopts, NULL)) 187 (opt = getopt_long(argc, argv, "cxtzvOf:X:pC:", longopts, NULL))
187#endif 188#endif
188 > 0) { 189 > 0) {
189 switch (opt) { 190 switch (opt) {
@@ -240,6 +241,13 @@ extern int tar_main(int argc, char **argv)
240#endif 241#endif
241 case 'p': 242 case 'p':
242 break; 243 break;
244 case 'C':
245 cwd = xgetcwd((char *)cwd);
246 if (chdir(optarg)) {
247 printf("cd: %s: %s\n", optarg, strerror(errno));
248 return EXIT_FAILURE;
249 }
250 break;
243 default: 251 default:
244 show_usage(); 252 show_usage();
245 } 253 }
@@ -292,6 +300,8 @@ extern int tar_main(int argc, char **argv)
292#endif 300#endif
293 } 301 }
294 302
303 if (cwd)
304 chdir(cwd);
295 if (status == TRUE) 305 if (status == TRUE)
296 return EXIT_SUCCESS; 306 return EXIT_SUCCESS;
297 else 307 else
diff --git a/include/usage.h b/include/usage.h
index d68652fe5..acba3677c 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -1154,9 +1154,10 @@
1154 "221 foobar closing connection\n" 1154 "221 foobar closing connection\n"
1155 1155
1156#define nslookup_trivial_usage \ 1156#define nslookup_trivial_usage \
1157 "[HOST]" 1157 "[HOST] [SERVER]"
1158#define nslookup_full_usage \ 1158#define nslookup_full_usage \
1159 "Queries the nameserver for the IP address of the given HOST" 1159 "Queries the nameserver for the IP address of the given HOST\n" \
1160 "optionally using a specified DNS server"
1160#define nslookup_example_usage \ 1161#define nslookup_example_usage \
1161 "$ nslookup localhost\n" \ 1162 "$ nslookup localhost\n" \
1162 "Server: default\n" \ 1163 "Server: default\n" \
@@ -1469,10 +1470,10 @@
1469#define tar_trivial_usage \ 1470#define tar_trivial_usage \
1470 "-[" USAGE_TAR_CREATE("c") "xtvO] " \ 1471 "-[" USAGE_TAR_CREATE("c") "xtvO] " \
1471 USAGE_TAR_EXCLUDE("[--exclude FILE] [-X FILE]") \ 1472 USAGE_TAR_EXCLUDE("[--exclude FILE] [-X FILE]") \
1472 "[-f TARFILE] [FILE(s)] ..." 1473 "[-f TARFILE] [-C DIR] [FILE(s)] ..."
1473#define tar_full_usage \ 1474#define tar_full_usage \
1474 "Create, extract, or list files from a tar file.\n\n" \ 1475 "Create, extract, or list files from a tar file.\n\n" \
1475 "Main operation mode:\n" \ 1476 "Options:\n" \
1476 USAGE_TAR_CREATE("\tc\t\tcreate\n") \ 1477 USAGE_TAR_CREATE("\tc\t\tcreate\n") \
1477 "\tx\t\textract\n" \ 1478 "\tx\t\textract\n" \
1478 "\tt\t\tlist\n" \ 1479 "\tt\t\tlist\n" \
@@ -1483,7 +1484,7 @@
1483 "\texclude\t\tfile to exclude\n" \ 1484 "\texclude\t\tfile to exclude\n" \
1484 "\tX\t\tfile with names to exclude\n" \ 1485 "\tX\t\tfile with names to exclude\n" \
1485 ) \ 1486 ) \
1486 "\nInformative output:\n" \ 1487 "\tC\t\tchange to directory DIR before operation\n" \
1487 "\tv\t\tverbosely list files processed" 1488 "\tv\t\tverbosely list files processed"
1488#define tar_example_usage \ 1489#define tar_example_usage \
1489 "$ zcat /tmp/tarball.tar.gz | tar -xf -\n" \ 1490 "$ zcat /tmp/tarball.tar.gz | tar -xf -\n" \
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)
151 char** excludeList=NULL; 151 char** excludeList=NULL;
152 char** extractList=NULL; 152 char** extractList=NULL;
153 const char *tarName="-"; 153 const char *tarName="-";
154 const char *cwd=NULL;
154#if defined BB_FEATURE_TAR_EXCLUDE 155#if defined BB_FEATURE_TAR_EXCLUDE
155 int excludeListSize=0; 156 int excludeListSize=0;
156 FILE *fileList; 157 FILE *fileList;
@@ -181,9 +182,9 @@ extern int tar_main(int argc, char **argv)
181 182
182 while ( 183 while (
183#ifndef BB_FEATURE_TAR_EXCLUDE 184#ifndef BB_FEATURE_TAR_EXCLUDE
184 (opt = getopt(argc, argv, "cxtzvOf:p")) 185 (opt = getopt(argc, argv, "cxtzvOf:pC:"))
185#else 186#else
186 (opt = getopt_long(argc, argv, "cxtzvOf:X:p", longopts, NULL)) 187 (opt = getopt_long(argc, argv, "cxtzvOf:X:pC:", longopts, NULL))
187#endif 188#endif
188 > 0) { 189 > 0) {
189 switch (opt) { 190 switch (opt) {
@@ -240,6 +241,13 @@ extern int tar_main(int argc, char **argv)
240#endif 241#endif
241 case 'p': 242 case 'p':
242 break; 243 break;
244 case 'C':
245 cwd = xgetcwd((char *)cwd);
246 if (chdir(optarg)) {
247 printf("cd: %s: %s\n", optarg, strerror(errno));
248 return EXIT_FAILURE;
249 }
250 break;
243 default: 251 default:
244 show_usage(); 252 show_usage();
245 } 253 }
@@ -292,6 +300,8 @@ extern int tar_main(int argc, char **argv)
292#endif 300#endif
293 } 301 }
294 302
303 if (cwd)
304 chdir(cwd);
295 if (status == TRUE) 305 if (status == TRUE)
296 return EXIT_SUCCESS; 306 return EXIT_SUCCESS;
297 else 307 else
diff --git a/usage.h b/usage.h
index d68652fe5..acba3677c 100644
--- a/usage.h
+++ b/usage.h
@@ -1154,9 +1154,10 @@
1154 "221 foobar closing connection\n" 1154 "221 foobar closing connection\n"
1155 1155
1156#define nslookup_trivial_usage \ 1156#define nslookup_trivial_usage \
1157 "[HOST]" 1157 "[HOST] [SERVER]"
1158#define nslookup_full_usage \ 1158#define nslookup_full_usage \
1159 "Queries the nameserver for the IP address of the given HOST" 1159 "Queries the nameserver for the IP address of the given HOST\n" \
1160 "optionally using a specified DNS server"
1160#define nslookup_example_usage \ 1161#define nslookup_example_usage \
1161 "$ nslookup localhost\n" \ 1162 "$ nslookup localhost\n" \
1162 "Server: default\n" \ 1163 "Server: default\n" \
@@ -1469,10 +1470,10 @@
1469#define tar_trivial_usage \ 1470#define tar_trivial_usage \
1470 "-[" USAGE_TAR_CREATE("c") "xtvO] " \ 1471 "-[" USAGE_TAR_CREATE("c") "xtvO] " \
1471 USAGE_TAR_EXCLUDE("[--exclude FILE] [-X FILE]") \ 1472 USAGE_TAR_EXCLUDE("[--exclude FILE] [-X FILE]") \
1472 "[-f TARFILE] [FILE(s)] ..." 1473 "[-f TARFILE] [-C DIR] [FILE(s)] ..."
1473#define tar_full_usage \ 1474#define tar_full_usage \
1474 "Create, extract, or list files from a tar file.\n\n" \ 1475 "Create, extract, or list files from a tar file.\n\n" \
1475 "Main operation mode:\n" \ 1476 "Options:\n" \
1476 USAGE_TAR_CREATE("\tc\t\tcreate\n") \ 1477 USAGE_TAR_CREATE("\tc\t\tcreate\n") \
1477 "\tx\t\textract\n" \ 1478 "\tx\t\textract\n" \
1478 "\tt\t\tlist\n" \ 1479 "\tt\t\tlist\n" \
@@ -1483,7 +1484,7 @@
1483 "\texclude\t\tfile to exclude\n" \ 1484 "\texclude\t\tfile to exclude\n" \
1484 "\tX\t\tfile with names to exclude\n" \ 1485 "\tX\t\tfile with names to exclude\n" \
1485 ) \ 1486 ) \
1486 "\nInformative output:\n" \ 1487 "\tC\t\tchange to directory DIR before operation\n" \
1487 "\tv\t\tverbosely list files processed" 1488 "\tv\t\tverbosely list files processed"
1488#define tar_example_usage \ 1489#define tar_example_usage \
1489 "$ zcat /tmp/tarball.tar.gz | tar -xf -\n" \ 1490 "$ zcat /tmp/tarball.tar.gz | tar -xf -\n" \