summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Dight <joe.dight@ntmail.uk>2022-06-28 12:47:06 +0100
committerJoe Dight <joe.dight@ntmail.uk>2022-06-28 13:18:18 +0100
commite18d0be2fb036f0832f4aaadc369359f9d19bf4a (patch)
tree1120c44874d47e5e205d524c4544e86398e8fdb9
parent7ab36f2732c84ee6cebdcfbd6d22b55a46979202 (diff)
Pass cell contents correctly when following links
-rw-r--r--src/file.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/file.c b/src/file.c
index ccdd6b3..a21430f 100644
--- a/src/file.c
+++ b/src/file.c
@@ -2172,10 +2172,13 @@ int backup_exists(char * file) {
void openfile_nested(char * file) {
char * cmd = get_conf_value("default_open_file_under_cursor_cmd");
if (cmd == NULL || ! strlen(cmd)) return;
- char syscmd[PATHLEN + strlen(cmd)];
- sprintf(syscmd, "%s", cmd);
- sprintf(syscmd + strlen(syscmd), " %s", file);
- system(syscmd);
+ pid_t pid = fork();
+ if (pid == 0) {
+ execlp(cmd, cmd, file, NULL);
+ exit(EXIT_FAILURE);
+ } else if (pid > 0) {
+ waitpid(pid, NULL, 0);
+ }
}