summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCiprian Dorin Craciun <ciprian@volution.ro>2017-07-19 22:46:03 +0300
committerNed T. Crigler <crigler@gmail.com>2025-06-17 08:15:03 -0700
commit1e462729c1bc7325bb1126a674d1fb7b91cf836a (patch)
treed5593eecb7dab2468c2b7217b23502ed40b82d34
parentedb19a321c4e15e660426acb68581578a67c5576 (diff)
Add support for -- argument termination marker
This allows one to have executables starting with -; another side-effect of this patch is that in case dtach is used in a script where we can't trust the user input, now the user is not able to inject new options that are interpreted by dtach; (for example it is used like dtach -c socket -- ${@} (cherry picked from commit ff35a7e791225f8d28a27033658070bbb4caa5ff)
-rw-r--r--main.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/main.c b/main.c
index 9fe78b8..89e22ce 100644
--- a/main.c
+++ b/main.c
@@ -152,6 +152,11 @@ main(int argc, char **argv)
{
char *p;
+ if (strcmp(argv[0], "--") == 0) {
+ ++argv; --argc;
+ break;
+ }
+
for (p = argv[0] + 1; *p; ++p)
{
if (*p == 'E')