Bug#885938: Parameter substitution highlighting when dash provides /bin/sh
James McCoy
jamessan at debian.org
Mon Jan 1 04:07:58 UTC 2018
Hi Charles,
Given this shell script
#!/bin/sh
echo ${FOO#bar}
the # is highlighted as an error when /bin/sh is provided by dash. This
is a similar issue to one I had reported before with process
substitution.
That was fixed by adding an '|| exists("b:is_posix")' check before
defining shCommandSub. The attached sh.vim-param.diff implements a
similar fix for shDerefOp.
However, I wonder if there's a better fix for these issues. They were
introduced by the sh.vim update from v147 to v151 (https://github.com/vim/vim/commit/91c4937be15b0b743b6bc495df602c1abbff6b87#diff-3684eb3d10603a1e201bf60108720b02).
Prior to that sh.vim update, the g:is_* variables would be set based on
the detected shell (g:is_posix for dash). After that, the buffer-local
variables would be set, which would result in b:is_kornshell being set.
if executable("/bin/sh")
let s:shell = resolve("/bin/sh")
elseif executable("/usr/bin/sh")
let s:shell = resolve("/usr/bin/sh")
endif
if s:shell =~ 'bash$'
let g:is_bash= 1
elseif s:shell =~ 'ksh$'
let g:is_kornshell = 1
elseif s:shell =~ 'dash$'
let g:is_posix = 1
endif
...
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
After that sh.vim update, b:is_posix is set when dash is detected, which
bypasses the g:is_* variable -> buffer-local conversion, so now dash is
operating with b:is_posix and b:is_sh set instead of b:is_kornshell.
Would it be better to revert that part of the sh.vim update or possibly
set both b:is_kornshell and b:is_posix for dash? Then ksh specific code
could check for is_kornshell and !is_posix.
Cheers,
--
James
GPG Key: 4096R/91BF BF4D 6956 BD5D F7B7 2D23 DFE6 91AE 331B A3DB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sh.vim-param.diff
Type: text/x-diff
Size: 783 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-vim-maintainers/attachments/20171231/e4cfe2c0/attachment.diff>
More information about the pkg-vim-maintainers
mailing list