Skip to content

Commit 48581f2

Browse files
sahinfchrisbra
authored andcommitted
runtime(vim9): Fix dist#vim9#Open() spaced paths and SIGPIPE crashes
Problem: dist#vim9#Open() fails to open files with spaces on Linux because Launch() splits the command string. Also, background GUI viewers (e.g., xdg-open) crash with SIGPIPE when Vim destroys the default job_start() IO pipes. Solution: Use job_start() with 'sh -c' to let the POSIX shell parse the shellescaped quotes safely. Set 'in_io', 'out_io', and 'err_io' to 'null' to completely detach the background process and prevent pipe crashes. Unify the Launch() execution block across all operating systems. closes: #19928 fixes: #19916 Signed-off-by: Furkan Sahin <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 365d58a commit 48581f2

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

runtime/autoload/dist/vim9.vim

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ vim9script
33
# Vim runtime support library
44
#
55
# Maintainer: The Vim Project <https://github.com/vim/vim>
6-
# Last Change: 2026 Mar 10
6+
# Last Change: 2026 Apr 06
77

88
export def IsSafeExecutable(filetype: string, executable: string): bool
99
if empty(exepath(executable))
@@ -62,7 +62,7 @@ if has('unix')
6262
export def Launch(args: string)
6363
# Use job_start, because using !xdg-open is known not to work with zsh
6464
# ignore signals on exit
65-
job_start(split(args), {'stoponexit': ''})
65+
job_start(['sh', '-c', args], {'stoponexit': '', 'in_io': 'null', 'out_io': 'null', 'err_io': 'null'})
6666
enddef
6767
endif
6868
elseif has('win32')
@@ -139,13 +139,7 @@ export def Open(file: string)
139139
setlocal shell&
140140
defer setbufvar('%', '&shell', shell)
141141
endif
142-
if has('unix') && !has('win32unix') && !exists('$WSL_DISTRO_NAME')
143-
# Linux: using job_start, so do not use shellescape.
144-
Launch($"{Viewer()} {file}")
145-
else
146-
# Windows/WSL/Cygwin: NEEDS shellescape because Launch uses '!'
147-
Launch($"{Viewer()} {shellescape(file, 1)}")
148-
endif
142+
Launch($"{Viewer()} {shellescape(file, 1)}")
149143
enddef
150144

151145
# Uncomment this line to check for compilation errors early

0 commit comments

Comments
 (0)