6
6
" Last Change: 2024 Mar 04 by Vim Project
7
7
" 2024 Nov 03 by Aliaksei Budavei <0x000c70 AT gmail DOT com> (improved bracket expressions, #15941)
8
8
" 2025 Jan 06 add $PS0 to bashSpecialVariables (#16394)
9
+ " 2025 Jan 18 add bash coproc, remove duplicate syn keywords (#16467)
9
10
" Version: 208
10
11
" Former URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH
11
12
" For options and settings, please use: :help ft-sh-syntax
@@ -24,7 +25,7 @@ elseif getline(1) =~ '\<bash\>'
24
25
elseif getline (1 ) = ~ ' \<dash\>'
25
26
let b: is_dash = 1
26
27
elseif ! exists (" g:is_kornshell" ) && ! exists (" g:is_bash" ) && ! exists (" g:is_posix" ) && ! exists (" g:is_sh" ) && ! exists (" g:is_dash" )
27
- " user did not specify which shell to use, and
28
+ " user did not specify which shell to use, and
28
29
" the script itself does not specify which shell to use. FYI: /bin/sh is ambiguous.
29
30
" Assuming /bin/sh is executable, and if its a link, find out what it links to.
30
31
let s: shell = " "
@@ -352,7 +353,7 @@ if exists("b:is_bash")
352
353
ShFoldIfDoFor syn region shCase contained skipwhite skipnl matchgroup= shSnglCase start = " \% (\\ .\| [^#$()'" \t ]\)\{ - }\z s)" end=" ;;" end=" ;& " end=" ;;& " end=" esac" me=s-1 contains=@shCaseList nextgroup=shCaseStart,shCase,shComment
353
354
elseif exists (" b:is_kornshell" )
354
355
ShFoldIfDoFor syn region shCase contained skipwhite skipnl matchgroup= shSnglCase start = " \% (\\ .\| [^#$()'" \t ]\)\{ - }\z s)" end=" ;;" end=" ;& " end=" esac" me=s-1 contains=@shCaseList nextgroup=shCaseStart,shCase,shComment
355
- else
356
+ else
356
357
ShFoldIfDoFor syn region shCase contained skipwhite skipnl matchgroup= shSnglCase start = " \% (\\ .\| [^#$()'" \t ]\)\{ - }\z s)" end=" ;;" end=" esac" me=s-1 contains=@shCaseList nextgroup=shCaseStart,shCase,shComment
357
358
endif
358
359
ShFoldIfDoFor syn region shCaseEsac matchgroup= shConditional start = " \< case\> " end = " \< esac\> " contains= @s hCaseEsacList
@@ -405,7 +406,7 @@ syn region shCmdParenRegion matchgroup=shCmdSubRegion start="((\@!" skip='\\\\\|
405
406
if exists (" b:is_bash" )
406
407
syn cluster shCommandSubList add =bashSpecialVariables,bashStatement
407
408
syn cluster shCaseList add =bashAdminStatement,bashStatement
408
- syn keyword bashSpecialVariables contained auto_resume BASH BASH_ALIASES BASH_ALIASES BASH_ARGC BASH_ARGC BASH_ARGV BASH_ARGV BASH_CMDS BASH_CMDS BASH_COMMAND BASH_COMMAND BASH_ENV BASH_EXECUTION_STRING BASH_EXECUTION_STRING BASH_LINENO BASH_LINENO BASHOPTS BASHOPTS BASHPID BASHPID BASH_REMATCH BASH_REMATCH BASH_SOURCE BASH_SOURCE BASH_SUBSHELL BASH_SUBSHELL BASH_VERSINFO BASH_VERSION BASH_XTRACEFD BASH_XTRACEFD CDPATH COLUMNS COLUMNS COMP_CWORD COMP_CWORD COMP_KEY COMP_KEY COMP_LINE COMP_LINE COMP_POINT COMP_POINT COMPREPLY COMPREPLY COMP_TYPE COMP_TYPE COMP_WORDBREAKS COMP_WORDBREAKS COMP_WORDS COMP_WORDS COPROC COPROC DIRSTACK EMACS EMACS ENV ENV EUID FCEDIT FIGNORE FUNCNAME FUNCNAME FUNCNEST FUNCNEST GLOBIGNORE GROUPS histchars HISTCMD HISTCONTROL HISTFILE HISTFILESIZE HISTIGNORE HISTSIZE HISTTIMEFORMAT HISTTIMEFORMAT HOME HOSTFILE HOSTNAME HOSTTYPE IFS IGNOREEOF INPUTRC LANG LC_ALL LC_COLLATE LC_CTYPE LC_CTYPE LC_MESSAGES LC_NUMERIC LC_NUMERIC LINENO LINES LINES MACHTYPE MAIL MAILCHECK MAILPATH MAPFILE MAPFILE OLDPWD OPTARG OPTERR OPTIND OSTYPE PATH PIPESTATUS POSIXLY_CORRECT POSIXLY_CORRECT PPID PROMPT_COMMAND PS0 PS1 PS2 PS3 PS4 PWD RANDOM READLINE_LINE READLINE_LINE READLINE_POINT READLINE_POINT REPLY SECONDS SHELL SHELL SHELLOPTS SHLVL TIMEFORMAT TIMEOUT TMPDIR TMPDIR UID
409
+ syn keyword bashSpecialVariables contained auto_resume BASH BASH_ALIASES BASH_ARGC BASH_ARGV BASH_CMDS BASH_COMMAND BASH_ENV BASH_EXECUTION_STRING BASH_LINENO BASHOPTS BASHPID BASH_REMATCH BASH_SOURCE BASH_SUBSHELL BASH_VERSINFO BASH_VERSION BASH_XTRACEFD CDPATH COLUMNS COMP_CWORD COMP_KEY COMP_LINE COMP_POINT COMPREPLY COMP_TYPE COMP_WORDBREAKS COMP_WORDS COPROC COPROC_PID DIRSTACK EMACS ENV EUID FCEDIT FIGNORE FUNCNAME FUNCNEST GLOBIGNORE GROUPS histchars HISTCMD HISTCONTROL HISTFILE HISTFILESIZE HISTIGNORE HISTSIZE HISTTIMEFORMAT HOME HOSTFILE HOSTNAME HOSTTYPE IFS IGNOREEOF INPUTRC LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_NUMERIC LINENO LINES MACHTYPE MAIL MAILCHECK MAILPATH MAPFILE OLDPWD OPTARG OPTERR OPTIND OSTYPE PATH PIPESTATUS POSIXLY_CORRECT PPID PROMPT_COMMAND PS0 PS1 PS2 PS3 PS4 PWD RANDOM READLINE_LINE READLINE_POINT REPLY SECONDS SHELL SHELLOPTS SHLVL TIMEFORMAT TIMEOUT TMPDIR UID
409
410
syn keyword bashStatement chmod clear complete du egrep expr fgrep find gnufind gnugrep grep head less ls mkdir mv rm rmdir rpm sed sleep sort strip tail
410
411
syn keyword bashAdminStatement daemon killall killproc nice reload restart start status stop
411
412
syn keyword bashStatement command compgen
@@ -540,6 +541,7 @@ if !exists("b:is_posix")
540
541
endif
541
542
542
543
if exists (" b:is_bash" )
544
+ syn keyword shFunctionKey coproc
543
545
ShFoldFunctions syn region shFunctionOne matchgroup= shFunction start = " ^\s *[A-Za-z_0-9:][-a-zA-Z_0-9:]*\s *()\_ s*{" end = " }" contains= @s hFunctionList skipwhite skipnl nextgroup= shFunctionStart,shQuickComment
544
546
ShFoldFunctions syn region shFunctionTwo matchgroup= shFunction start = " \% (do\)\@ !\&\< [A-Za-z_0-9:][-a-zA-Z_0-9:]*\>\s *\% (()\)\=\_ s*{" end = " }" contains= shFunctionKey,@s hFunctionList contained skipwhite skipnl nextgroup= shFunctionStart,shQuickComment
545
547
ShFoldFunctions syn region shFunctionThree matchgroup= shFunction start = " ^\s *[A-Za-z_0-9:][-a-zA-Z_0-9:]*\s *()\_ s*(" end = " )" contains= @s hFunctionList skipwhite skipnl nextgroup= shFunctionStart,shQuickComment
@@ -693,10 +695,10 @@ if exists("b:is_kornshell") || exists("b:is_posix")
693
695
" Additional bash Keywords: {{{1
694
696
" =====================
695
697
elseif exists (" b:is_bash" )
696
- syn keyword shStatement bg builtin disown export false fg getopts jobs let printf sleep true unalias
698
+ syn keyword shStatement bg builtin disown export false fg getopts jobs let printf true unalias
697
699
syn keyword shStatement typeset nextgroup =shSetOption
698
700
syn keyword shStatement fc hash history source suspend times type
699
- syn keyword shStatement bind builtin caller compopt declare dirs disown enable export help logout local mapfile popd pushd readarray shopt source typeset
701
+ syn keyword shStatement bind caller compopt declare dirs enable help logout local mapfile popd pushd readarray shopt typeset
700
702
else
701
703
syn keyword shStatement login newgrp
702
704
endif
0 commit comments