summaryrefslogtreecommitdiff
path: root/src/install.c
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2023-04-21 19:07:02 +0100
committerPádraig Brady <P@draigBrady.com>2023-04-21 19:13:52 +0100
commit6bab375973e62e9fcc0b41451d637134073e3007 (patch)
tree9d4f445e56585b7f2c482ab939c39884d37c63c3 /src/install.c
parentf6229adb09b9ace9bd0034a2c228fcee224c0563 (diff)
downloadcoreutils-6bab375973e62e9fcc0b41451d637134073e3007.tar.gz
install: support stripping files with a leading hyphen
* src/install.c (strip): Prepend "./" to file names with a leading "-". * tests/install/strip-program.sh: Add a test case. * NEWS: Mention the bug fix. Reported in https://bugs.debian.org/1034429
Diffstat (limited to 'src/install.c')
-rw-r--r--src/install.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/install.c b/src/install.c
index 3aa6ea92b..272dfcb8f 100644
--- a/src/install.c
+++ b/src/install.c
@@ -502,8 +502,13 @@ strip (char const *name)
error (0, errno, _("fork system call failed"));
break;
case 0: /* Child. */
- execlp (strip_program, strip_program, name, NULL);
- die (EXIT_FAILURE, errno, _("cannot run %s"), quoteaf (strip_program));
+ {
+ char const *safe_name = name;
+ if (name && *name == '-')
+ safe_name = file_name_concat (".", name, NULL);
+ execlp (strip_program, strip_program, safe_name, NULL);
+ die (EXIT_FAILURE, errno, _("cannot run %s"), quoteaf (strip_program));
+ }
default: /* Parent. */
if (waitpid (pid, &status, 0) < 0)
error (0, errno, _("waiting for strip"));