-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
feat: add env for write_jar_script again #20010
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
base: master
Are you sure you want to change the base?
Conversation
I believe this cause some error on |
Library/Homebrew/extend/pathname.rb
Outdated
@@ -433,7 +433,8 @@ def write_jar_script(target_jar, script_name, java_opts = "", java_version: nil, | |||
mkpath | |||
(self/script_name).write <<~SH | |||
#!/bin/bash | |||
#{env_export}exec "${JAVA_HOME}/bin/java" #{java_opts} -jar "#{target_jar}" "$@" | |||
#{env_export} |
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.
These won't be exported if on the line before.
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.
Tried same as before, add export
and line break.
It looks like |
Here is the
JAVA_HOME should be evaluated but it does not, right? How can I? |
9d5b73a
to
84074cb
Compare
It maybe needs a preceding |
Maybe this can solve the problem? def write_jar_script(target_jar, script_name, java_opts = "", java_version: nil, env: {})
env[:JAVA_HOME] ||= Language::Java.overridable_java_home_env(java_version)[:JAVA_HOME]
env_export = env.map do |key, value|
%(export #{key}="#{value.gsub('"', '\"')}")
end.join("\n")
mkpath
(self/script_name).write <<~EOS
#!/bin/bash
#{env_export}
exec "${JAVA_HOME}/bin/java" #{java_opts} -jar "#{target_jar}" "$@"
EOS
end |
e7ddb49
to
d1e040d
Compare
d1e040d
to
d23fb25
Compare
d23fb25
to
970b970
Compare
#!/bin/bash | ||
export JAVA_HOME="#{Language::Java.overridable_java_home_env(java_version)[:JAVA_HOME]}" | ||
exec "${JAVA_HOME}/bin/java" #{java_opts} -jar "#{target_jar}" "$@" | ||
EOS | ||
#{env_export}exec "${JAVA_HOME}/bin/java" #{java_opts} -jar "#{target_jar}" "$@" |
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.
I think either:
env ENV=var exec
or
export ENV=var
exec
are needed here for valid syntax.
Either way, please ensure you've tested this and found it to be working locally before marking this as non-draft
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?I think I missed line break from