From bdfc149a3a0fa6e0ed40b1b981e520dcf4613952 Mon Sep 17 00:00:00 2001 From: jae beller Date: Fri, 30 Jan 2026 19:06:55 -0500 Subject: [PATCH] Fix backslash escapes for `-o ssh_command` The option previously supported escaping spaces with backslash, but this was broken at some point. Spaces are correctly skipped, but the backslashes are never removed. As a result, it is impossible to use commands with arguments that include spaces. Note that escaping requires a double backslash. The first backslash is always removed by `fuse_opt_parse`'s own escape handling. --- sshfs.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sshfs.c b/sshfs.c index 4abaf63..87b94a0 100644 --- a/sshfs.c +++ b/sshfs.c @@ -3931,6 +3931,7 @@ static char *tokenize_on_space(char *str) { static char *pos = NULL; char *start = NULL; + char *end = NULL; if (str) pos = str; @@ -3943,22 +3944,27 @@ static char *tokenize_on_space(char *str) pos++; start = pos; + end = pos; while (pos && *pos != '\0') { // break on space, but not on '\ ' - if (*pos == ' ' && *(pos - 1) != '\\') { - break; + if (*pos == ' ') { + if (*(pos - 1) == '\\') { + end--; + } else { + break; + } } - pos++; + *end++ = *pos++; } if (*pos == '\0') { pos = NULL; } else { - *pos = '\0'; pos++; } + *end = '\0'; return start; }