Commit c470960ab3abd5b9d2c70062d7bd1d6c51f6359e
system, term, ...: correctly handle commands starting with `-`
Currently, at least with bash and zsh, vifm is unable to run a command
whose name starts with a dash (`-`) inside of a `term()` or `system()`
call:
zsh: bad option string: '-fd-compgen <...>'
Fix this by applying the idiomatic `--` guard to the shell invocation
(by convention and by POSIX, `--` denotes end of options).
Author: Ivan Shapovalov
Author date (UTC): 2024-04-11 17:41
Committer name: Ivan Shapovalov
Committer date (UTC): 2024-04-11 17:41
Parent(s): e95c30ab2669eee19efe0ea89045f6b8f0ab4ee0
Signing key:
Tree: fe429ff4fa763b64ee5e4ddfe8f778575dcc07af
File src/utils/utils_nix.c changed (mode: 100644) (index 856d9fb47..eef5a6e3c) |
... |
... |
make_execv_array(char shell[], char shell_flag[], char cmd[]) |
358 |
358 |
|
|
359 |
359 |
char name[NAME_MAX + 1]; |
char name[NAME_MAX + 1]; |
360 |
360 |
|
|
361 |
|
char **args = reallocarray(NULL, 4 + npieces + 1, sizeof(*args)); |
|
|
361 |
|
char **args = reallocarray(NULL, 5 + npieces + 1, sizeof(*args)); |
362 |
362 |
char *eval_cmd; |
char *eval_cmd; |
363 |
363 |
size_t len; |
size_t len; |
364 |
364 |
size_t i; |
size_t i; |
|
... |
... |
make_execv_array(char shell[], char shell_flag[], char cmd[]) |
376 |
376 |
args[i++] = sh_arg; |
args[i++] = sh_arg; |
377 |
377 |
} |
} |
378 |
378 |
args[i++] = shell_flag; |
args[i++] = shell_flag; |
|
379 |
|
args[i++] = "--"; |
379 |
380 |
args[i++] = cmd; |
args[i++] = cmd; |
380 |
381 |
args[i++] = NULL; |
args[i++] = NULL; |
381 |
382 |
return args; |
return args; |