]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0560: filetype: busybox shebang lines are not recognized v9.2.0560
authorChristoffer Aasted <dezzadk@gmail.com>
Fri, 29 May 2026 18:31:35 +0000 (18:31 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 29 May 2026 18:31:35 +0000 (18:31 +0000)
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 <dezzadk@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/autoload/dist/script.vim
src/testdir/test_filetype.vim
src/version.c

index 0106900f8f54e00e2f94dfdb6d85c9c5f4cff1ab..3f9a5acfd0638a180cb147e233ca27a98ce85f35 100644 (file)
@@ -45,6 +45,8 @@ def DetectFromHashBang(firstline: string)
     name = substitute(line1, '^#!.*\<env\>\s\+\(\i\+\).*', '\1', '')
   elseif line1 =~ '^#!\s*[^/\\ ]*\>\([^/\\]\|$\)'
     name = substitute(line1, '^#!\s*\([^/\\ ]*\>\).*', '\1', '')
+  elseif line1 =~ '^#!.*\<busybox\>'
+    name = substitute(line1, '^#!.*\<busybox\>\s\+\(\i\+\).*', '\1', '')
   else
     name = substitute(line1, '^#!\s*\S*[/\\]\(\f\+\).*', '\1', '')
   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
index 3e6a538a8299123d9790b77f4e970dfde2621918..f4fd2002a1e45be4646eac2a9d87bfd71e2aa42e 100644 (file)
@@ -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']],
index f77ed07b9b1088706d898a8456349115ed6b3f97..cb845499e4726d1ff7f3a86a604bda1c369f5190 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    560,
 /**/
     559,
 /**/