diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-25 01:32:45 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-25 01:32:45 +0200 |
commit | f645037ffb156dbca22296c1453f0b45383ff8ce (patch) | |
tree | a2d3fc5e02fe4a31bf7c17c23ea8714bcec9e3d9 | |
parent | b87d972817d39fc2c9a0c11ea2578431628bfd7d (diff) | |
download | busybox-w32-f645037ffb156dbca22296c1453f0b45383ff8ce.tar.gz busybox-w32-f645037ffb156dbca22296c1453f0b45383ff8ce.tar.bz2 busybox-w32-f645037ffb156dbca22296c1453f0b45383ff8ce.zip |
tar: handle "tar fx TARFILE" etc
function old new delta
tar_main 702 751 +49
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/tar.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/archival/tar.c b/archival/tar.c index bd8e5dc99..3c0ceb70d 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -841,6 +841,33 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
841 | #if ENABLE_FEATURE_TAR_LONG_OPTIONS | 841 | #if ENABLE_FEATURE_TAR_LONG_OPTIONS |
842 | applet_long_options = tar_longopts; | 842 | applet_long_options = tar_longopts; |
843 | #endif | 843 | #endif |
844 | #if ENABLE_DESKTOP | ||
845 | if (argv[1][0] != '-') { | ||
846 | /* Compat: | ||
847 | * 1st argument without dash handles options with parameters | ||
848 | * differently from dashed one: it takes *next argv[i]* | ||
849 | * as paramenter even if there are more chars in 1st argument: | ||
850 | * "tar fx TARFILE" - "x" is not taken as f's param | ||
851 | * but is interpreted as -x option | ||
852 | * "tar -xf TARFILE" - dashed equivalent of the above | ||
853 | * "tar -fx ..." - "x" is taken as f's param | ||
854 | * getopt32 wouldn't handle 1st command correctly. | ||
855 | * Unfortunately, people do use such commands. | ||
856 | * We massage argv[1] to work around it by moving 'f' | ||
857 | * to the end of the string. | ||
858 | * More contrived "tar fCx TARFILE DIR" still fails, | ||
859 | * but such commands are much less likely to be used. | ||
860 | */ | ||
861 | char *f = strchr(argv[1], 'f'); | ||
862 | if (f) { | ||
863 | while (f[1] != '\0') { | ||
864 | *f = f[1]; | ||
865 | f++; | ||
866 | } | ||
867 | *f = 'f'; | ||
868 | } | ||
869 | } | ||
870 | #endif | ||
844 | opt = getopt32(argv, | 871 | opt = getopt32(argv, |
845 | "txC:f:Opvk" | 872 | "txC:f:Opvk" |
846 | IF_FEATURE_TAR_CREATE( "ch" ) | 873 | IF_FEATURE_TAR_CREATE( "ch" ) |