unzip applet not working ?
Dan Fandrich
dan at coneharvesters.com
Thu Jun 14 19:50:52 UTC 2012
On Wed, Jun 13, 2012 at 07:37:13PM +0200, John Spencer wrote:
> I could trace it back to
>
> /* '-' makes getopt return 1 for non-options */
> while ((opt = getopt(argc, argv, "-d:lnopqxv")) != -1)
>
> this returns *not* 1 with musl. according to Rich the commented
> behaviour is a gnuism and not POSIX.
I've run into the same issue. Attached is the patch I use to work around
it.
>>> Dan
-------------- next part --------------
From 69a11fe970d58ff7a826720ad4b8b6685ab6a4d6 Mon Sep 17 00:00:00 2001
From: Dan Fandrich <dan at coneharvesters.com>
Date: Thu, 14 Jun 2012 12:44:00 -0700
Subject: [PATCH] Fixed unzip to work with non-GNU getopt
Signed-off-by: Dan Fandrich <dan at coneharvesters.com>
---
archival/unzip.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/archival/unzip.c b/archival/unzip.c
index c1b945a..e66e2b8 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -409,6 +409,21 @@ int unzip_main(int argc, char **argv)
}
}
+#ifndef __GLIBC__
+ /*
+ * This is a fallback that only happen with a non-GNU getopt()
+ * The -d and -x options are not honoured in that case.
+ */
+ if (optind < argc) {
+ /* +5: space for ".zip" and NUL */
+ src_fn = xmalloc(strlen(argv[optind]) + 5);
+ strcpy(src_fn, argv[optind]);
+
+ while (++optind < argc)
+ llist_add_to(&zaccept, argv[optind]);
+ }
+#endif
+
if (src_fn == NULL) {
bb_show_usage();
}
--
1.5.3.2
More information about the busybox
mailing list