vim-syntastic / syntastic

Syntax checking hacks for vim
Do What The F*ck You Want To Public License
11.3k stars 1.14k forks source link

Bash (sh) checker does nothing #665

Closed Thanatermesis closed 11 years ago

Thanatermesis commented 11 years ago

There's a long time that I have noticed that the bash checker doesn't works anymore (sh checker), actually the external checker works well (bash -n) but seems like the checker simply doesn't run it

Unfortunately I don't know much about viml so I can't help more with the problem or debugging the cause

This is an example script that should trigger warnings in the checker: http://paste.debian.net/7764/

Thanks

lcd047 commented 11 years ago

I can't seem to reproduce the problem:

2013-05-31-143937_433x215

Then again, the sh checker does some bizarre gymnastics. On what system are you running this? Please also run the checker and post the output of :SyntasticInfo and :echo b:shell.

Thanatermesis commented 11 years ago

:SyntasticInfo Syntastic info for filetype: sh Available checkers: checkbashisms sh Currently active checker(s): sh

:echo b:shell bash

Thanatermesis commented 11 years ago

Interesting! It doesn't works when my system is in spanish language, i disabled the language variables and it worked

This is the checker (out of vim) result that i got in spanish:

[thana ~ ]$ bash -n /tmp/cleanup-photos.sh /tmp/cleanup-photos.sh: línea 35: error sintáctico: no se esperaba el final del fichero

lcd047 commented 11 years ago

Right: most (if not all) checkers assume the English locales, otherwise errorformat would never match. I'll try to think of a solution for re-setting the locales before running the checkers.

Thanatermesis commented 11 years ago

Seems like this does the job: syntax_checkers/sh/sh.vim: 69: \ 'exe': "LC_ALL=C " . s:GetShell(),

Note: I dont know viml syntax, it was just a fast hack test

lcd047 commented 11 years ago

Yes, but there should be a more general solution, that applies to all checkers, across all systems.

Thanatermesis commented 11 years ago

Since all checkers can have a similar issue, maybe could be a good idea to unset the language for run the check ? (by other side is good to have the messages in the users's language), mmh...

lcd047 commented 11 years ago

I'm still not entirely convinced this is the right fix, but it's a best effort attempt. :)

Thanatermesis commented 11 years ago

Thankyou, I was waiting for this fix :), we can move to a better one if its found, but its not a bad one, is not the first time that I have see that locales are reseted before to parse something, in order to be parsed as how is defined

lcd047 commented 11 years ago

To be clear, my doubt is about Windows systems. We'll have to see if it breaks anything...

Thanatermesis commented 11 years ago

If windows don't use this variable, I don't think that can break anything... maybe the messages stills on other languages on a windows environment, but you know... windows is not a stable "distro" or environment to work :) nobody will notice that something is breaked (since everything is) lol

idleyoungman commented 11 years ago

This broke puppet syntax checking when the manifest being checked includes Unicode chars, such as:

file { '/var/www/html/index.html' :
    ensure  => present,
    content => '<a href=\'http://en.wikipedia.org/wiki/Ægir\'>dereference</a>'
}

The puppet parser validate invocation returns invalid byte sequence in US-ASCII.

puppet parser validate foo.pp works fine w/ LC_ALL=en_US.UTF-8, but gives the same error when LC_ALL=C. I understand that non-ASCII in source files may be a corner case and that this is a thorny issue, but passing it on nonetheless.

lcd047 commented 11 years ago

Hmm. You can work around this problem by adding something like this to your vimrc:

let g:syntastic_puppet_puppet_exe = "LC_ALL=en_US.UTF-8 puppet"
idleyoungman commented 11 years ago

With these set in .vimrc:

let g:syntastic_debug=1
let g:syntastic_puppet_puppet_exe='LC_ALL=en_US.UTF-8 puppet'

Debug output is:

syntastic: debug: CacheErrors: Invoking checker: puppet
syntastic: debug: SyntasticMake: called with options: {'errorformat': '%-Gerr: Try ''puppet help parser validate'' for usage,%-GError: Try ''puppet help parser validate'' for usage,%Eerr: Could not parse for environment %*[a-z]: %m at %f:%l,%EError: Could not parse for environment %*[a-z]: %m at %f:%l', 'makeprg': 'LC_ALL=en_US.UTF-8 puppet parser validate --color=false ''foo.pp''  '}
syntastic: debug: getLocList: checker puppet/puppet returned 0
syntastic: debug: CacheErrors: Invoking checker: puppetlint
syntastic: debug: SyntasticMake: called with options: {'errorformat': '%t%*[a-zA-Z] %m at %f:%l', 'makeprg': 'puppet-lint  ''foo.pp'' --log-format "\%{KIND} [\%{check}] \%{message} at \%{fullpath}:\%{linenumber}" '}
syntastic: debug: getLocList: checker puppet/puppetlint returned 1
lcd047 commented 11 years ago

I'm not sure what I'm supposed to see here... As far as I can tell, the puppet checker succeeds and the puppetlint checker fails. If you are using puppet-lint, you should, of course, apply the same workaround for it:

let g:syntastic_puppet_puppetlint_exe = "LC_ALL=en_US.UTF-8 puppet-lint"
idleyoungman commented 11 years ago

Ah, of course. Sorry for the noise.

lcd047 commented 11 years ago

I added a note to that effect to the wiki pages for puppet and puppetlint.