Commit: patch 9.1.0965: filetype: sh filetype set when detecting the use of bash

10 views
Skip to first unread message

Christian Brabandt

unread,
Dec 27, 2024, 10:15:11 AM12/27/24
to vim...@googlegroups.com
patch 9.1.0965: filetype: sh filetype set when detecting the use of bash

Commit: https://github.com/vim/vim/commit/b9b762c21f2b61e0e7d8fee43d4d3dc8ecffd721
Author: Luca Saccarola <github...@aleeas.com>
Date: Fri Dec 27 16:08:14 2024 +0100

patch 9.1.0965: filetype: sh filetype set when detecting the use of bash

Problem: filetype: sh filetype set when detecting the use of bash
Solution: when bash is detected, use 'bash' filetype instead
(Luca Saccarola)

closes: #16309

Signed-off-by: Luca Saccarola <github...@aleeas.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 0936a85ed..ce7f44fa6 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -896,6 +896,7 @@ export def SetFileTypeSH(name: string, setft = true): string
if exists("b:is_sh")
unlet b:is_sh
endif
+ return SetFileTypeShell("bash", setft)
elseif name =~ '\<sh\>' || name =~ '\<dash\>'
# Ubuntu links "sh" to "dash", thus it is expected to work the same way
b:is_sh = 1
diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim
index 27ced5207..6b1f0fb8e 100644
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -128,6 +128,10 @@ def s:GetFilenameChecks(): dict<list<string>>
awk: ['file.awk', 'file.gawk'],
b: ['file.mch', 'file.ref', 'file.imp'],
basic: ['file.bas', 'file.bi', 'file.bm'],
+ bash: ['.bashrc', '.bash_profile', '.bash-profile', '.bash_logout',
+ '.bash-logout', '.bash_aliases', '.bash-aliases', '.bash_history',
+ '.bash-history', '/tmp/bash-fc-3Ozjlw', '/tmp/bash-fc.3Ozjlw', 'PKGBUILD',
+ 'file.bash', 'file.bats', 'file.cygport'],
bass: ['file.bass'],
bc: ['file.bc'],
bdf: ['file.bdf'],
@@ -685,11 +689,12 @@ def s:GetFilenameChecks(): dict<list<string>>
services: ['/etc/services', 'any/etc/services'],
setserial: ['/etc/serial.conf', 'any/etc/serial.conf'],
sexplib: ['file.sexp'],
- sh: ['.bashrc', '.bash_profile', '.bash-profile', '.bash_logout', '.bash-logout', '.bash_aliases', '.bash-aliases', '.bash_history', '.bash-history',
- '/tmp/bash-fc-3Ozjlw', '/tmp/bash-fc.3Ozjlw', 'PKGBUILD', 'file.bash', '/usr/share/doc/bash-completion/filter.sh',
- '/etc/udev/cdsymlinks.conf', 'any/etc/udev/cdsymlinks.conf', 'file.bats', '.ash_history', 'any/etc/neofetch/config.conf', '.xprofile',
- 'user-dirs.defaults', 'user-dirs.dirs', 'makepkg.conf', '.makepkg.conf', 'file.mdd', 'file.cygport', '.env', '.envrc', 'devscripts.conf',
- '.devscripts', 'file.lo', 'file.la', 'file.lai'],
+ sh: ['/usr/share/doc/bash-completion/filter.sh',
+ '/etc/udev/cdsymlinks.conf', 'any/etc/udev/cdsymlinks.conf',
+ '.ash_history', 'any/etc/neofetch/config.conf', '.xprofile',
+ 'user-dirs.defaults', 'user-dirs.dirs', 'makepkg.conf', '.makepkg.conf',
+ 'file.mdd', '.env', '.envrc', 'devscripts.conf', '.devscripts', 'file.lo',
+ 'file.la', 'file.lai'],
sieve: ['file.siv', 'file.sieve'],
sil: ['file.sil'],
simula: ['file.sim'],
@@ -984,11 +989,11 @@ def s:GetScriptChecks(): dict<list<list<string>>>
clojure: [['#!/path/clojure']],
scala: [['#!/path/scala']],
sh: [['#!/path/sh'],
- ['#!/path/bash'],
- ['#!/path/bash2'],
['#!/path/dash'],
['#!/path/ksh'],
['#!/path/ksh93']],
+ bash: [['#!/path/bash'],
+ ['#!/path/bash2']],
csh: [['#!/path/csh']],
tcsh: [['#!/path/tcsh']],
zsh: [['#!/path/zsh']],
diff --git a/src/version.c b/src/version.c
index e1e0e36bc..622a0a1c6 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 965,
/**/
964,
/**/

Rob Foehl

unread,
Dec 27, 2024, 11:56:34 AM12/27/24
to vim...@googlegroups.com
On Fri, 2024-12-27 at 16:15 +0100, Christian Brabandt wrote:
>     patch 9.1.0965: filetype: sh filetype set when detecting the use of bash
>    
>     Problem:  filetype: sh filetype set when detecting the use of bash
>     Solution: when bash is detected, use 'bash' filetype instead
>               (Luca Saccarola)

Why? This is a breaking change, even with the half-assed hack that is
ftplugin/bash.vim present.

-Rob
Reply all
Reply to author
Forward
0 new messages