Forward quoted shell parameters to installed tools #22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The install script installs shims which forward arguments to
stack
, but the current forwarding isn't perfect. Specifically, if you try to pass a multi-word or quoted argument through these shims, those words get split up onIFS
and the words get passed along individually.For example,
ghc
supports evaluating expressions directly with the-e
flag, such thatHowever, because these shims use
$*
, any quoted parameters are first expanded, then split onIFS
, and then forwarded along:That's because with
$*
, the above command effectively expands toand each word is forwarded individually;
-e
applies only to theputStrLn
argument, andghc
chokes onHello,
, expecting a source file. Instead, using"$@"
for all parameters correctly keeps multi-word and quoted input as-is, allowing all arguments to be correctly forwarded to the underlying binaries.This affects installing
haskell-language-server
, ashaskell-language-server-wrapper
attempts to discover the full path to GHC viastack exec ghc -- -v0 -package-env=- -e "do e <- System.Environment.getExecutablePath ; System.IO.putStr e"
and GHC gets each of those words as a separate parameter:With these changes, on my system, I see the expected
and I can confirm that
haskell-language-server-wrapper
runs successfully.What is the difference between $* and $@? on the Unix & Linux StackExchange has some really instructive examples of why you might want to prefer
"$@"
over$*
(and"$*"
, and even plain$@
).