commit 646305c01d71c32db6b54d08c7cd54503bf5055d
parent 54121a1877ea2ca0ca593913fcabd93742956870
Author: xplshn <anto@xplshn.com.ar>
Date: Sat, 21 Nov 2026 13:34:37 -0300
install: keep argc after moving options
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/cmd/extra/install.c b/cmd/extra/install.c
@@ -170,8 +170,9 @@ install_one(const char *src, const char *dst)
// makefiles write "install file -m 644 dest": options may follow operands, so
// move them in front of the first operand before they are parsed
static char **
-options_first(int argc, char **argv)
+options_first(int *argcp, char **argv)
{
+ int argc = *argcp;
char **out = ecalloc(argc + 2, sizeof(*out));
int n = 0, i, rest = 0;
@@ -206,6 +207,7 @@ options_first(int argc, char **argv)
out[n++] = argv[i];
}
out[n] = NULL;
+ *argcp = n;
return out;
}
@@ -221,7 +223,7 @@ main(int argc, char *argv[])
int isdir;
int i;
- argv = options_first(argc, argv);
+ argv = options_first(&argc, argv);
ARGBEGIN
{
// ?man -c: ignored; accepted for compatibility with older install callers