hello from shellcheck
shellcheck has some hints what could be improved and some of the are worth a look:
$ shellcheck cargo.sh
In cargo.sh line 9:
SCRIPT_PATH=`realpath $0`
^-- SC2034: SCRIPT_PATH appears unused. Verify use (or export if used externally).
^-- SC2006: Use $(..) instead of legacy `..`.
^-- SC2086: Double quote to prevent globbing and word splitting.
In cargo.sh line 10:
SOURCE_DIR=`dirname $0`
^-- SC2006: Use $(..) instead of legacy `..`.
^-- SC2086: Double quote to prevent globbing and word splitting.
In cargo.sh line 12:
export CARGO_TARGET_DIR=`pwd`
^-- SC2155: Declare and assign separately to avoid masking return values.
^-- SC2006: Use $(..) instead of legacy `..`.
In cargo.sh line 13:
if [ ! -z ${1} ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.
In cargo.sh line 14:
OUT_PATH=`realpath "${1}"`
^-- SC2006: Use $(..) instead of legacy `..`.
In cargo.sh line 17:
cd $SOURCE_DIR
^-- SC2086: Double quote to prevent globbing and word splitting.
In cargo.sh line 19:
cargo $BUILD_ARG $@
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2068: Double quote array expansions to avoid re-splitting elements.
In cargo.sh line 21:
if [ ! -z ${OUT_PATH} ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.