From b49492f13ce34c242546e5a3e768b2937ebddeba Mon Sep 17 00:00:00 2001 From: tao <2471314@gmail.com> Date: Thu, 11 Jun 2026 05:28:17 +0800 Subject: fix(option): set 'shell…' options based on detected shell #40031 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: * 'shellcmdflag' states that its default value is set according to the value of 'shell', but this behavior is not yet implemented on Windows. The same applies to 'shellpipe', 'shellredir', and 'shellxquote'. * On Windows, Git is often installed in paths containing spaces, and we still do not correctly resolve the sh executable name as described in 'shell'. * On Windows, the default value of 'shellslash' is always `false`, which causes Unix-like shells to interpret `\` in paths returned by some functions as escape charaters. Solution: Use a simple rule table to detect common shells (e.g. `cmd`, `powershell`, shells whose names contain `csh` or `sh`) and apply best-effort defaults, while leaving more complex scenarios to user configuration. --- runtime/lua/vim/_meta/options.gen.lua | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/_meta/options.gen.lua b/runtime/lua/vim/_meta/options.gen.lua index 3e2e24e7fc..0895207bd2 100644 --- a/runtime/lua/vim/_meta/options.gen.lua +++ b/runtime/lua/vim/_meta/options.gen.lua @@ -5914,12 +5914,12 @@ vim.go.shcf = vim.go.shellcmdflag --- For MS-Windows the default is "2>&1| tee". The stdout and stderr are --- saved in a file and echoed to the screen. --- For Unix the default is "| tee". The stdout of the compiler is saved ---- in a file and echoed to the screen. If the 'shell' option is "csh" or ---- "tcsh" after initializations, the default becomes "|& tee". If the ---- 'shell' option is "sh", "ksh", "mksh", "pdksh", "zsh", "zsh-beta", ---- "bash", "fish", "ash" or "dash" the default becomes "2>&1| tee". This ---- means that stderr is also included. Before using the 'shell' option a ---- path is removed, thus "/bin/sh" uses "sh". +--- in a file and echoed to the screen. If the 'shell' option contains +--- "csh" (e.g. "tcsh") after initializations, the default becomes +--- "|& tee". Otherwise, if it contains "sh" (e.g. "bash", "zsh"), the +--- default becomes "2>&1| tee". This means that stderr is also included. +--- Before using the 'shell' option a path is removed, thus "/bin/sh" uses +--- "sh". --- The initialization of this option is done after reading the vimrc --- and the other initializations, so that when the 'shell' option is set --- there, the 'shellpipe' option changes automatically, unless it was @@ -5964,12 +5964,12 @@ vim.go.shq = vim.go.shellquote --- The name of the temporary file can be represented by "%s" if necessary --- (the file name is appended automatically if no %s appears in the value --- of this option). ---- The default is ">". For Unix, if the 'shell' option is "csh" or ---- "tcsh" during initializations, the default becomes ">&". If the ---- 'shell' option is "sh", "ksh", "mksh", "pdksh", "zsh", "zsh-beta", ---- "bash" or "fish", the default becomes ">%s 2>&1". This means that ---- stderr is also included. For Win32, the Unix checks are done and ---- additionally "cmd" is checked for, which makes the default ">%s 2>&1". +--- The default is ">". For Unix, if the 'shell' option contains "csh" +--- (e.g. "tcsh") during initializations, the default becomes ">&". +--- Otherwise, if it contains "sh" (e.g. "bash", "zsh"), the default +--- becomes ">%s 2>&1". This means that stderr is also included. For +--- Win32, the Unix checks are done and additionally "cmd" is checked +--- for, which makes the default ">%s 2>&1". --- Also, the same names with ".exe" appended are checked for. --- The initialization of this option is done after reading the vimrc --- and the other initializations, so that when the 'shell' option is set -- cgit