summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog6
-rw-r--r--archival/tar.c7
-rw-r--r--tar.c7
3 files changed, 10 insertions, 10 deletions
diff --git a/Changelog b/Changelog
index e9fbdd0..44bcd37 100644
--- a/Changelog
+++ b/Changelog
@@ -16,10 +16,8 @@
* Fixed ping warnings -- fix from Sascha Ziemann <szi@aibon.ping.de>
* Fixed update segfault
* Fixed mknod -- minor number was always 0
- * Fixed tar option parsing. In an attempt to accomodate the whiners
- that wanted "tar cf foo.tar foo" (i.e. no "-" before options)
- I broke creation of tarballs. I reverted the change (so tar needs
- the "-" for all options).
+ * Fixed tar option parsing, so both "tar xvf foo.tar" and "tar -xvf foo.tar"
+ now work (i.e. no "-" before options) (this was very broken in 0.43).
* Several contributions from Randolph Chung <tausq@debian.org>.
* cp/mv now accepts the -f flag
* tail can now accept -<num> commands (e.g. -10) for better
diff --git a/archival/tar.c b/archival/tar.c
index c5aad45..7d440f4 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -173,7 +173,7 @@ extern int tar_main(int argc, char **argv)
#if defined BB_FEATURE_TAR_EXCLUDE
int excludeListSize=0;
#endif
- const char *tarName=NULL;
+ const char *tarName="-";
int listFlag = FALSE;
int extractFlag = FALSE;
int createFlag = FALSE;
@@ -187,13 +187,13 @@ extern int tar_main(int argc, char **argv)
/* Parse any options */
while (--argc > 0 && strspn(*(++argv), "-cxt") >0 ) {
stopIt=FALSE;
- while (stopIt==FALSE && *(++(*argv))) {
+ while (stopIt==FALSE && *argv && **argv) {
switch (**argv) {
case 'f':
if (--argc == 0) {
fatalError( "Option requires an argument: No file specified\n");
}
- if (tarName != NULL)
+ if (*tarName != '-')
fatalError( "Only one 'f' option allowed\n");
tarName = *(++argv);
if (tarName == NULL)
@@ -252,6 +252,7 @@ extern int tar_main(int argc, char **argv)
fatalError( "Unknown tar flag '%c'\n"
"Try `tar --help' for more information\n", **argv);
}
+ ++(*argv);
}
}
diff --git a/tar.c b/tar.c
index c5aad45..7d440f4 100644
--- a/tar.c
+++ b/tar.c
@@ -173,7 +173,7 @@ extern int tar_main(int argc, char **argv)
#if defined BB_FEATURE_TAR_EXCLUDE
int excludeListSize=0;
#endif
- const char *tarName=NULL;
+ const char *tarName="-";
int listFlag = FALSE;
int extractFlag = FALSE;
int createFlag = FALSE;
@@ -187,13 +187,13 @@ extern int tar_main(int argc, char **argv)
/* Parse any options */
while (--argc > 0 && strspn(*(++argv), "-cxt") >0 ) {
stopIt=FALSE;
- while (stopIt==FALSE && *(++(*argv))) {
+ while (stopIt==FALSE && *argv && **argv) {
switch (**argv) {
case 'f':
if (--argc == 0) {
fatalError( "Option requires an argument: No file specified\n");
}
- if (tarName != NULL)
+ if (*tarName != '-')
fatalError( "Only one 'f' option allowed\n");
tarName = *(++argv);
if (tarName == NULL)
@@ -252,6 +252,7 @@ extern int tar_main(int argc, char **argv)
fatalError( "Unknown tar flag '%c'\n"
"Try `tar --help' for more information\n", **argv);
}
+ ++(*argv);
}
}