Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced exit status handling? #54

Closed
esamattis opened this issue Feb 17, 2017 · 6 comments
Closed

Advanced exit status handling? #54

esamattis opened this issue Feb 17, 2017 · 6 comments

Comments

@esamattis
Copy link
Contributor

I was looking on how to add support for PHP_CodeSniffer formatting but it uses non zero exit codes for non errors:

  • Exit code 0 is now used to indicate that no fixable errors were found, and so nothing was fixed
  • Exit code 1 is now used to indicate that all fixable errors were fixed correctly
  • Exit code 2 is now used to indicate that PHPCBF failed to fix some of the fixable errors it found
  • Exit code 3 is now used for general script execution errors

https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.0.0RC3

I according to this exit codes 1 and 2 should be whitelisted from the neoformat error handling.

@sbdchd
Copy link
Owner

sbdchd commented Feb 17, 2017

I think it would be best to make PHP_CodeSniffer use the generally accepted Posix exit codes: http://tldp.org/LDP/abs/html/exitcodes.html

However, I would be open to adding an option for formatters that decide to go rogue with their exit codes.

@esamattis
Copy link
Contributor Author

I totally agree with you. I opened issue on PHP_CodeSniffer squizlabs/PHP_CodeSniffer#1359

@esamattis
Copy link
Contributor Author

They are not interested in fixing it.

How about adding an optional callback function which validates the exit codes?

@sbdchd
Copy link
Owner

sbdchd commented Feb 22, 2017

An optional callback could be created, but it will require some work since Neoformat currently uses v:shell_error after calling system() to check if the command error.

Here is the relevant doc:

v:shell_error Result of the last shell command. When non-zero, the last
shell command had an error. When zero, there was no problem.
This only works when the shell returns the error code to Vim.
The value -1 is often used when the command could not be
executed. Read-only.
Example:

:!mv foo bar
:if v:shell_error
:  echo 'could not rename "foo" to "bar"!'
:endif

@esamattis
Copy link
Contributor Author

The v:shell_error does seem to contain the command exit code

:call system("exit 4")
:echo v:shell_error
4

so it should not be too much work.

@sbdchd
Copy link
Owner

sbdchd commented Feb 3, 2018

See new config variables:

https://github.com/sbdchd/neoformat#config-optional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants