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
Treat xcrun --sdk macosx swift
as a single command
#16
Conversation
…of course I forgot to test on a script without shebang. Such a script results in this error:
A workaround might be disabling hashbang parsing for Swift files, otherwise I fear this’ll require changes to TM::Executor.
|
I believe this has the same cause as #12 |
When running a script containing a correct hashbang, like #!/usr/bin/env xcrun --sdk macosx swift the TextMate::Executor would replace the *first* element of `command` with the parsed hashbang command. This results in TextMate trying to execute commands like /usr/bin/env xcrun --sdk macosx swift --sdk macosx swift which fails because swift(1) doesn’t accept an `--sdk` parameter. This change specifies the whole `xcrun … swift` command as a single element, which it is anyway conceptually, and which fixes this problem.
So, the simplest thing that works: This change now works for files with and without shebangs. |
I assume you’re implying that This is a change that I think would actually be good in general because many run commands will pass Though it does cause an issue when there is a space in the path to the interpreter. |
I assume we are talking about https://github.com/textmate/bundle-support.tmbundle/blob/master/Support/shared/lib/tm/executor.rb#L89-L91 ? |
@jtbandes Yes |
No, because of spaces in filenames. |
I just tested the #!/usr/bin/env swift
import Cocoa
print("Hello, world!") So it seems that the macOS SDK is default now, at least with the latest (release not beta) version of Xcode. Not to short circuit talk of improving TM::Executor. :) |
@mkhl I've got a commit here with a simplified Run command: Any problems running your code with this change? |
@infininight That works just fine, thanks. If we merge that, should we update the shebang snippets to match? |
Added as b3cb437. |
Some “Run Script” commands supply arguments to the executable that may lead to errors, which caused for example textmate/swift.tmbundle#16. This change adds a `default_args` option to `#run` which is appended to the command line when there is *no* hashbang line (or parsing them is disabled). “Run Script” type commands in other bundles will need updating to take advantage of this change.
When running a script containing a correct hashbang, like
the TextMate::Executor would replace the first element of
command
with the parsed hashbang command.This results in TextMate trying to execute commands like
which fails because swift(1) doesn’t accept an
--sdk
parameter.This change specifies the whole
xcrun … swift
command as a single element, which it is anyway conceptually, and which fixes this problem.