ctubbsii commented on a change in pull request #21: Add debug flag to runex
Fixes #18
URL: https://github.com/apache/accumulo-examples/pull/21#discussion_r180589698
##########
File path: bin/runex
##########
@@ -16,10 +16,24 @@
# limitations under the License.
main_class="$1"
-main_args="${*:2}"
+mvn_opts="-q"
+main_args=()
+
+shift
+while [[ $# -gt 0 ]] ; do
+ case $1 in
+ -d|--debug)
+ mvn_opts="-X"
+ ;;
+ *)
+ main_args+=("$1")
+ ;;
+ esac
+ shift
+done
if command -v accumulo > /dev/null 2>&1 ; then
av_arg="-Daccumulo.version=`accumulo version | tail -n 1`"
fi
-mvn -q exec:java -Dlog4j.configuration="file:./conf/log4j.properties"
-Dexec.mainClass="org.apache.accumulo.examples.$main_class" $av_arg
-Dexec.args="$main_args"
+mvn $mvn_opts exec:java -Dlog4j.configuration="file:./conf/log4j.properties"
-Dexec.mainClass="org.apache.accumulo.examples.$main_class" $av_arg
-Dexec.args="${main_args[@]}"
Review comment:
This is not going to expand the way you think. To see why, do:
```bash
main_args=(a b)
for x in exec.args="${main_args[@]}"; do echo $x; done
for x in exec.args="${main_args[*]}"; do echo $x; done
```
In the first example, the `@` causes it to expand, but the `-Dexec.args=`
part is only associated with the first element. The rest are treated as
separate arguments to the `mvn` command-line.
In the second example, the `*` causes it to expand with spaces in the same
quoted string, as part of the same single `-Dexec.args=` parameter being passed
to the `mvn` command-line.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services