Closed Craige closed 5 years ago
I can't repeat the bug here. You'll have to let me know which linter specifically this is a problem for. The executable path is escaped for phpcs
.
I was having this problem specifically with phpcs
Can you include the output when this is a problem? Note that the file containing the space in the path will have to be executable for the command to run.
How do I get the output beyond what I've included above?
Just :ALEInfo
is enough. If the executable check fails, that means the file wasn't executable, so the command wasn't run.
I posted the :ALEInfo
output in the initial ticket...
Unless @w0rp has a different opinion, I think this is a non-issue (and thus wontfix).
What's going on here is simple: you've passed a command to ALE, expending it to pass the second, space-separated component as an argument, and thus invoke a subcommand. What is instead happening is that ALE is searching for a command with a space in the filename.
More simply put, ALE is executing 'bin/passthrough phpcs'
, and you want it to execute 'bin/passthrough' 'phpcs'
.
This is a quirk of *nix filesystems in general, and shell argument splitting in general. Other common tools, such as git, behave the same here (try setting $EDITOR
to a command with spaces in it), and as such I think that escaping any and all spaces in the command is the expected behavior (and thus acting like exec(2), instead of a shell).
If you want to avoid code duplication in your wrapper scripts, a common Unix idiom is dynamic dispatch based on argv[0]. This variable ($0
in POSIX sh) is populated with the exact string used to invoke your script, and you can use it to change your script's behavior, not unlike a subcommand. Simply symlink your wrapper to different names, and you can invoke as many variations as you want.
Let me know if you have any additional questions! I'll probably try to follow up with better documentation of how ALE parses commands in the future.
I think a general documentation entry explaining how shell escaping works would be fine, which we could reference in every _executable
documentation section. Executable paths are quoted, and that is how it's supposed to work. I think specific issues with specific linters can be handled separately, such as adding support for running scripts via other tools. There is a general option for wrapping any command in scripts, which works to some degree. See :help g:ale_command_wrapper
.
Information
Executable name for linters do not perform correctly when they contain a space. Eg:
bin/passthrough phpcs
fails to append parameters and flags to the command where asbin/phpcs-passthrough
succeeds.VIM version VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Aug 29 2017 23:29:43) MacOS X (unix) version
Operating System: WHAT OS WERE YOU USING? OS X 10.12.6
:ALEInfo
PASTE OUTPUT OF
:ALEInfo
HERE. YOU CAN TRY:ALEInfoToClipboard
.vs
What went wrong
ALE broke when the executable command contain a space (technically, the "command" was a path to a script and a parameter to pass to trigger a subroutine). This is undesirable.
Reproducing the bug
Steps for repeating the bug:
bin/stript parameter-denoting-subroutine-to-trigger