Example build hardening
* run_example.sh checks example existens
the script exits if without example name parameter
or if example directory doesn't exist
* Update examples/run_example.sh
* Update examples/run_example.sh
@@ -58,8 +58,20 @@ on_exit() {
trap on_exit EXIT
+if [[ -z "$EXAMPLE" ]]; then
+ fail "$0 requires the name of the example as the first argument"
+ info "See the README.md file for help"
+ exit
+fi
+
SRCDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" # this source dir
+if [[ ! -d "$SRCDIR/$EXAMPLE" || "$EXAMPLE" = "common" || "$EXAMPLE" = "server" ]]; then
+ fail "$EXAMPLE: no such example"
+ info "See the README.md file for help"
+ exit
+fi
+
cd "$SRCDIR/$EXAMPLE" # "$SRCDIR" ensures that this script can be run from anywhere.
# When using $CARGO_TARGET_DIR -> binary is located in different folder
