Use standard shell script extension

This makes it easier for developers and editors to recognise the file format.
Simplify Cygwin format conversion
Use $(cmd) in favour of deprecated `cmd` command substitution
Use a single variable for mutually exclusive options

Also removes unused "MINGW"/"msys" option.
Try to change ulimit, don't ask
Print warnings and error messages to standard error
Use reliable, simple code to get application home directory

Based on <https://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in>.https://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
Simplify error handling
Simplify root directories pattern creation
Simplify check for empty string
Remove unnecessary `exec` keyword
Simplify handling of JVM options

Also less error prone than combining unquoted variables, `eval` and arrays.
Apply recommended practices for quoting

- When mixing variables with literals or other variables, use curly
  brackets to delimit them.
- Make the script able to handle variables which are expected to be
  undefined.