-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Use CRYSTAL_OPTS env variable as default compiler options #8900
Conversation
Just bikesheddding, but why |
No special reasons. I'm happy to change it. |
I'm fine with that name too, I was just curious. |
@@ -585,4 +590,8 @@ class Crystal::Command | |||
@color = false if ARGV.includes?("--no-color") || ENV["TERM"]? == "dumb" | |||
Crystal.error msg, @color, exit_code: exit_code | |||
end | |||
|
|||
private def use_crystal_opts | |||
@options = ENV.fetch("CRYSTAL_OPTS", "").split.concat(options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a declaration that nobody will ever need to use spaces within options to Crystal compiler?
Would be nice to support shell quoting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Definitely an improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a safe already way to split that respecting shell quoting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. We'd need to port this from Ruby: https://ruby-doc.org/stdlib-2.5.1/libdoc/shellwords/rdoc/Shellwords.html (or do something similar)
Fixed crystal-lang#9509 Ref crystal-lang#8900 (comment) This commit adds `Process.split`, which works as like `Shellwords.split` in Ruby. And, this is used to parse `CRYSTAL_OPTS`. I'm not sure `Process.split` is good naming. However I have no idea of better name. And also, I'm not sure Windows version of `Process.split` is needed.
* Fix `CRYSTAL_OPTS` parsing Fixed #9509 Ref #8900 (comment) This commit adds `Process.split`, which works as like `Shellwords.split` in Ruby. And, this is used to parse `CRYSTAL_OPTS`. I'm not sure `Process.split` is good naming. However I have no idea of better name. And also, I'm not sure Windows version of `Process.split` is needed. * Rename `Process.split` to `parse_arguments` * Use `in?` instead of `includes?` Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl> * Let `Process.parse_arguments` raise an error against unclosed quote This also fix backslash behavior in double quote as POSIX. * Handle error on `CRYSTAL_OPTS` parsing Co-authored-by: Jonne Haß <me@jhass.eu> * Remove debug output from example Co-authored-by: Brian J. Cardiff <bcardiff@gmail.com> * Fix method name in example Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl> Co-authored-by: Jonne Haß <me@jhass.eu> Co-authored-by: Brian J. Cardiff <bcardiff@gmail.com>
This PR make the compiler read the
CRYSTAL_OPTS
environment variable and use is as additional compiler flags in some commands: build, eval, run, spec and .This is handy to configure the compiler to be more pedantic regarding deprecations for example. The compiler is sometimes used in postinstall tasks where injecting flags is not possible.
With this and #8899 we should be able to checks deprecation along all the source code used to build and app.