[launcher] basename for solaris#6711
Conversation
|
I will have @mrnoname1000 look at this since he has helped with this script recently. The original introduction of |
|
I was just testing something and I got a weird error at startup. I didn't find any similar report, but probably there aren't many Solaris users of JRuby. https://unix.stackexchange.com/questions/253524/dirname-and-basename-vs-parameter-expansion |
|
Looks like POSIX doesn't allow options to basename, so this is another GNU-ism we need to work around. Fortunately, basename operates purely on text, so it's pretty easy to implement in pure shell: basename() {
local base="$1"
if [ -n "$base" ]; then
# remove trailing slashes
base=${base%"${base##*[!/]}"}
# remove leading directories
base=${base##*/}
# if $1 is all slashes, base=/
base=${base:-/}
fi
printf "%s\n" "$base"
}The printf can be replaced with an alternate return method to avoid a subshell, such as Also basename has a little-used feature to remove a suffix, this function doesn't implement that. |
|
@mrnoname1000 Perhaps I should merge this as-is and you can push another PR with the pure-POSIX basename change? |
|
Actually I overlooked that stackexchange link, the implementation there looks better than mine and seems more efficient. I'll create a PR with that instead. |
it fails on launch because "--" isn't a valid java command (it works on linux)
returns "java" on both platforms