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
e61ad7f80b
commit
d4f2488eac
@ -1,26 +1,29 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
declare -A EXAMPLE_MAP=(
|
EXAMPLE_MAP=(
|
||||||
['spdy-server']='io.netty.example.spdy.server.SpdyServer'
|
'spdy-server:io.netty.example.spdy.server.SpdyServer'
|
||||||
['spdy-client']='io.netty.example.spdy.client.SpdyClient'
|
'spdy-client:io.netty.example.spdy.client.SpdyClient'
|
||||||
)
|
)
|
||||||
|
|
||||||
EXAMPLE=''
|
EXAMPLE=''
|
||||||
EXAMPLE_CLASS=''
|
EXAMPLE_CLASS=''
|
||||||
EXAMPLE_ARGS=''
|
EXAMPLE_ARGS='-D_'
|
||||||
I=0
|
I=0
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
ARG="$1"
|
ARG="$1"
|
||||||
shift
|
shift
|
||||||
if [[ "$ARG" =~ (^-.+) ]]; then
|
if [[ "$ARG" =~ (^-.+) ]]; then
|
||||||
if [[ -z "$EXAMPLE_ARGS" ]]; then
|
|
||||||
EXAMPLE_ARGS="$ARG"
|
|
||||||
else
|
|
||||||
EXAMPLE_ARGS="$EXAMPLE_ARGS $ARG"
|
EXAMPLE_ARGS="$EXAMPLE_ARGS $ARG"
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
EXAMPLE="$ARG"
|
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
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -32,8 +35,8 @@ if [[ -z "$EXAMPLE" ]] || [[ -z "$EXAMPLE_CLASS" ]] || [[ $# -ne 0 ]]; then
|
|||||||
echo >&2
|
echo >&2
|
||||||
echo "Available examples:" >&2
|
echo "Available examples:" >&2
|
||||||
echo >&2
|
echo >&2
|
||||||
for E in "${!EXAMPLE_MAP[@]}"; do
|
for E in "${EXAMPLE_MAP[@]}"; do
|
||||||
echo " $E"
|
echo " ${E%%:*}"
|
||||||
done | sort >&2
|
done | sort >&2
|
||||||
echo >&2
|
echo >&2
|
||||||
exit 1
|
exit 1
|
||||||
@ -41,5 +44,5 @@ fi
|
|||||||
|
|
||||||
cd "`dirname "$0"`"/example
|
cd "`dirname "$0"`"/example
|
||||||
echo "[INFO] Running: $EXAMPLE ($EXAMPLE_CLASS $EXAMPLE_ARGS)"
|
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