patch 9.2.0560: filetype: busybox shebang lines are not recognized
Commit:
https://github.com/vim/vim/commit/69f402e97f9f8e5dbf17549c4813cf932c91a4ee
Author: Christoffer Aasted <[email protected]>
Date: Fri May 29 18:31:35 2026 +0000
patch 9.2.0560: filetype: busybox shebang lines are not recognized
Problem: filetype: busybox shebang lines are not recognized
Solution: Add filetype detection pattern for #!busybox sh, detect
ash as shell in the shebang lines (Christoffer Aasted).
closes: #20358
Signed-off-by: Christoffer Aasted <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/runtime/autoload/dist/script.vim b/runtime/autoload/dist/script.vim
index 0106900f8..3f9a5acfd 100644
--- a/runtime/autoload/dist/script.vim
+++ b/runtime/autoload/dist/script.vim
@@ -45,6 +45,8 @@ def DetectFromHashBang(firstline: string)
name = substitute(line1, '^#!.*\<env\>\s\+\(\i\+\).*', ' ', '')
elseif line1 =~ '^#!\s*[^/\ ]*\>\([^/\]\|$\)'
name = substitute(line1, '^#!\s*\([^/\ ]*\>\).*', ' ', '')
+ elseif line1 =~ '^#!.*\<busybox\>'
+ name = substitute(line1, '^#!.*\<busybox\>\s\+\(\i\+\).*', ' ', '')
else
name = substitute(line1, '^#!\s*\S*[/\]\( \+\).*', ' ', '')
endif
@@ -67,7 +69,7 @@ enddef
# Returns an empty string when not recognized.
export def Exe2filetype(name: string, line1: string): string
# Bourne-like shell scripts: bash bash2 dash ksh ksh93 sh
- if name =~ '^\(bash\d*\|dash\|ksh\d*\|sh\)\>'
+ if name =~ '^\(bash\d*\|d\?ash\|ksh\d*\|sh\)\>'
return dist#ft#SetFileTypeSH(line1, false)
# csh scripts
diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim
index 3e6a538a8..f4fd2002a 100644
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -1089,7 +1089,10 @@ def s:GetScriptChecks(): dict<list<list<string>>>
['#!/path/bash2'],
['#!/path/dash'],
['#!/path/ksh'],
- ['#!/path/ksh93']],
+ ['#!/path/ksh93'],
+ ['#!/path/ash'],
+ ['#!/path/busybox ash'],
+ ['#!/path/busybox sh']],
csh: [['#!/path/csh']],
tcsh: [['#!/path/tcsh']],
zsh: [['#!/path/zsh']],
diff --git a/src/version.c b/src/version.c
index f77ed07b9..cb845499e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 560,
/**/
559,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1wT2Ce-00D5AN-6w%40256bit.org.