Allways outputs:
sbt requires at least version 6+, you have
version 0
- the quoted version word for findstr doesn't seem to work in the for-command statement, quotes not needed for a single word.
`-debug` is a legitimate command since 0.13.13, but it's been impossible to use it because Bash eats it. This allows log level to be set to debug level. (similar to `-warn` setting to warn level)
Ref https://github.com/sbt/sbt/pull/2742
I've reimplemented java version detection as a bash function.
This no longer uses grep.
Also this no longer uses `?` in sed, which doesn't work on macOS.
Fixes https://github.com/sbt/sbt/issues/3873
If -verbose:gc is set, there can be gc log output in this process that
prevents the directory from being properly extracted. Rather than
blacklist possible output strings, I think it makes more sense to
whitelist the specific output line that we're looking for.
Fixes#206
When I use unzipped sbt.bat it seems to runs ok, but using the msi installer version, this variable seems to expand and causes:
```
\sbt\bin\java9-rt-export.jar was unexpected at this time.
```
The flag can cause problems when there is another configuration
adding -Xms with a value bigger than 512M. The `java -version`
command will fail and no java version will be detected, causing
a failure in `checkJava`.
Fixessbt/sbt#3804
Inside the if, it seems like bunch of variables were set to blank.
Using delayed expansion seems to fix this. This is confirmed by the newly added test.
BSD sed interprets sed 's/\r//' as "replace the literal letter r". A more compatible approach delegates the interpretation of this sequence to bash.
Fixes#186
`java -version` can include an extra line of output
if `_JAVA_OPTTIONS` is set.
This commit adds a grep step before sed to harden
against this possibility.
Before:
```
⚡ (export _JAVA_OPTIONS=-Dfoo.bar; java -version 2>&1 | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q')
Picked up _JAVA_OPTIONS: -Dfoo.bar
```
After:
```
⚡ (export _JAVA_OPTIONS=-Dfoo.bar; java -version 2>&1 | grep ' version "' | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q')
1.8
```
Today you cannot have spaces in system properties:
$ sbt -Dfoo="bar baz" ...
It passes [-Dfoo=bar] and [baz] to java (see https://github.com/sbt/sbt/issues/2787).
This change allows you to do:
$ sbt "-Dfoo=bar baz"
which will pass ["-Dfoo=bar baz"]. And both of these two:
$ sbt "-Dfoo=bar"
$ sbt -Dfoo=bar
still work, passing [-Dfoo=bar].