Bash 3 compatibility
Motivation: Mac OS X ships Bash 3, and it does not have an associative array (declare -A). Modifications: Do not use an associative array. Result: Can run examples on Mac OS X using run-example.sh
This commit is contained in:
parent
579973e35a
commit
3051c1ee0f
@ -1,28 +1,31 @@
|
||||
#!/bin/bash -e
|
||||
declare -A EXAMPLE_MAP=(
|
||||
['spdy-server']='io.netty.example.spdy.server.SpdyServer'
|
||||
['spdy-client']='io.netty.example.spdy.client.SpdyClient'
|
||||
['http2-server']='io.netty.example.http2.server.Http2Server'
|
||||
['http2-client']='io.netty.example.http2.client.Http2Client'
|
||||
EXAMPLE_MAP=(
|
||||
'spdy-server:io.netty.example.spdy.server.SpdyServer'
|
||||
'spdy-client:io.netty.example.spdy.client.SpdyClient'
|
||||
'http2-server:io.netty.example.http2.server.Http2Server'
|
||||
'http2-client:io.netty.example.http2.client.Http2Client'
|
||||
)
|
||||
|
||||
EXAMPLE=''
|
||||
EXAMPLE_CLASS=''
|
||||
EXAMPLE_ARGS=''
|
||||
EXAMPLE_ARGS='-D_'
|
||||
I=0
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
ARG="$1"
|
||||
shift
|
||||
if [[ "$ARG" =~ (^-.+) ]]; then
|
||||
if [[ -z "$EXAMPLE_ARGS" ]]; then
|
||||
EXAMPLE_ARGS="$ARG"
|
||||
else
|
||||
EXAMPLE_ARGS="$EXAMPLE_ARGS $ARG"
|
||||
fi
|
||||
EXAMPLE_ARGS="$EXAMPLE_ARGS $ARG"
|
||||
else
|
||||
EXAMPLE="$ARG"
|
||||
EXAMPLE_CLASS="${EXAMPLE_MAP["$EXAMPLE"]}"
|
||||
for E in "${EXAMPLE_MAP[@]}"; do
|
||||
KEY="${E%%:*}"
|
||||
VAL="${E##*:}"
|
||||
if [[ "$EXAMPLE" == "$KEY" ]]; then
|
||||
EXAMPLE_CLASS="$VAL"
|
||||
break
|
||||
fi
|
||||
done
|
||||
break
|
||||
fi
|
||||
done
|
||||
@ -34,8 +37,8 @@ if [[ -z "$EXAMPLE" ]] || [[ -z "$EXAMPLE_CLASS" ]] || [[ $# -ne 0 ]]; then
|
||||
echo >&2
|
||||
echo "Available examples:" >&2
|
||||
echo >&2
|
||||
for E in "${!EXAMPLE_MAP[@]}"; do
|
||||
echo " $E"
|
||||
for E in "${EXAMPLE_MAP[@]}"; do
|
||||
echo " ${E%%:*}"
|
||||
done | sort >&2
|
||||
echo >&2
|
||||
exit 1
|
||||
@ -43,5 +46,5 @@ fi
|
||||
|
||||
cd "`dirname "$0"`"/example
|
||||
echo "[INFO] Running: $EXAMPLE ($EXAMPLE_CLASS $EXAMPLE_ARGS)"
|
||||
exec mvn -nsu compile exec:exec -DargLine.example="$EXAMPLE_ARGS" -DexampleClass="$EXAMPLE_CLASS"
|
||||
exec mvn -X -nsu compile exec:exec -DargLine.example="$EXAMPLE_ARGS" -DexampleClass="$EXAMPLE_CLASS"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user