Hi, On 19/12/16 14:02, James McCoy wrote: > On Mon, Dec 19, 2016 at 11:55:50AM +0100, Bas Zoetekouw wrote: >> Vim's currenr behaviour for syntax highlighting of shell scripts (with >> #!/bin/sh and /bin/sh pointing to dash) is to mark command >> substititions using the $(foo) construction as an error. > > Not that I can see.
I've just tried this with a clean strecht system (no ~/.vim* present):
screenshot is attached. The $(foo) is clearly marked as an error there
(inverse colors in this color scheme), in the same way as real bashisms
like $'' and ${foo%bar}.
>> This is incorrect, as POSIX sh alllows this construction.
>>
>> Because vim's syntaxt hightlighting script correctly identifies
>> /bin/sh-->/bin/dash as a POSIX shell, and sets b:is_posix,
>
> Which it then translates to b:is_kornshell:
>
> if !exists("b:is_kornshell") && !exists("b:is_bash")
> if exists("g:is_posix") && !exists("g:is_kornshell")
> let g:is_kornshell= g:is_posix
> endif
> if exists("g:is_kornshell")
> let b:is_kornshell= 1
> if exists("b:is_sh")
> unlet b:is_sh
> endif
>
> What b:is_ variable is set in that buffer? Also, see ":help
> ft-sh-syntax", although /bin/sh should be handled as POSIX if it's a
> symlink to dash.
In my case, vim seems to automatically set:
> filetype=sh
> syntax_on=#1
> b:current_syntax=sh
> b:is_posix=#1
> b:is_sh=#1
but no b_is_kornshell.
Not that in the piece you quoted, only g:is_posix is checked, whereas
sh.vim sets b:is_posix.
BTW, the syntax highlighting is correct if I change the hashbang to
/bin/ksh, /bin/bash or /bin/zsh, but not if I use /bin/sh (like in the
screenshot), /bin/dash, or /bin/ash
Gr,
Bas.
signature.asc
Description: OpenPGP digital signature

