66" Last Change: 2024 Mar 04 by Vim Project
77" 2024 Nov 03 by Aliaksei Budavei <0x000c70 AT gmail DOT com> (improved bracket expressions, #15941)
88" 2025 Jan 06 add $PS0 to bashSpecialVariables (#16394)
9+ " 2025 Jan 18 add bash coproc, remove duplicate syn keywords (#16467)
910" Version: 208
1011" Former URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH
1112" For options and settings, please use: :help ft-sh-syntax
@@ -24,7 +25,7 @@ elseif getline(1) =~ '\<bash\>'
2425elseif getline (1 ) = ~ ' \<dash\>'
2526 let b: is_dash = 1
2627elseif ! 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
2829 " the script itself does not specify which shell to use. FYI: /bin/sh is ambiguous.
2930 " Assuming /bin/sh is executable, and if its a link, find out what it links to.
3031 let s: shell = " "
@@ -352,7 +353,7 @@ if exists("b:is_bash")
352353 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
353354elseif exists (" b:is_kornshell" )
354355 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
356357 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
357358endif
358359ShFoldIfDoFor syn region shCaseEsac matchgroup= shConditional start = " \< case\> " end = " \< esac\> " contains= @s hCaseEsacList
@@ -405,7 +406,7 @@ syn region shCmdParenRegion matchgroup=shCmdSubRegion start="((\@!" skip='\\\\\|
405406if exists (" b:is_bash" )
406407 syn cluster shCommandSubList add =bashSpecialVariables,bashStatement
407408 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
409410 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
410411 syn keyword bashAdminStatement daemon killall killproc nice reload restart start status stop
411412 syn keyword bashStatement command compgen
@@ -540,6 +541,7 @@ if !exists("b:is_posix")
540541endif
541542
542543if exists (" b:is_bash" )
544+ syn keyword shFunctionKey coproc
543545 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
544546 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
545547 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")
693695" Additional bash Keywords: {{{1
694696" =====================
695697elseif 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
697699 syn keyword shStatement typeset nextgroup =shSetOption
698700 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
700702else
701703 syn keyword shStatement login newgrp
702704endif
0 commit comments