diff options
author | Quentin Schulz <quentin.schulz@theobroma-systems.com> | 2021-11-24 10:00:14 +0100 |
---|---|---|
committer | Quentin Schulz <quentin.schulz@theobroma-systems.com> | 2021-11-24 10:00:14 +0100 |
commit | c57f1996003437519320dbbd8d7a9936e19e27ab (patch) | |
tree | 3174bf6445d798ddf70490311f25cdf28b9b3b4c /mule | |
parent | e2a04dd61f98d57d2ba00026b1eb03489e05c9bd (diff) |
mule: mule.sh: prevent paths with spaces and/or globbing to mess up the script
Shellcheck returns the following warning:
SC2086: Double quote to prevent globbing and word splitting.
Let's fix this by double quoting variables where needed.
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Diffstat (limited to 'mule')
-rwxr-xr-x | mule/mule.sh | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/mule/mule.sh b/mule/mule.sh index 18cf3f5..5aaccd5 100755 --- a/mule/mule.sh +++ b/mule/mule.sh @@ -27,27 +27,27 @@ gpiosetup() { do PINNUM=$(echo "$PIN" | cut -d',' -f1) INVERT=$(echo "$PIN" | cut -d',' -f2) - if [ ! -d ${SYSFSPATH}/gpio${PINNUM} ] ; then - echo ${PINNUM} > ${SYSFSPATH}/export + if [ ! -d "${SYSFSPATH}/gpio${PINNUM}" ] ; then + echo "${PINNUM}" > "${SYSFSPATH}/export" fi - echo out > ${SYSFSPATH}/gpio${PINNUM}/direction - echo ${INVERT} > ${SYSFSPATH}/gpio${PINNUM}/active_low + echo out > "${SYSFSPATH}/gpio${PINNUM}/direction" + echo "${INVERT}" > "${SYSFSPATH}/gpio${PINNUM}/active_low" done } reset_stm32() { - echo 0 > ${SYSFSPATH}/gpio${RESET_PIN}/value - echo 0 > ${SYSFSPATH}/gpio${BOOT0_PIN}/value + echo 0 > "${SYSFSPATH}/gpio${RESET_PIN}/value" + echo 0 > "${SYSFSPATH}/gpio${BOOT0_PIN}/value" sleep 0.1 - echo 1 > ${SYSFSPATH}/gpio${RESET_PIN}/value + echo 1 > "${SYSFSPATH}/gpio${RESET_PIN}/value" } enable_dfu() { gpiosetup - echo 0 > ${SYSFSPATH}/gpio${RESET_PIN}/value - echo 1 > ${SYSFSPATH}/gpio${BOOT0_PIN}/value + echo 0 > "${SYSFSPATH}/gpio${RESET_PIN}/value" + echo 1 > "${SYSFSPATH}/gpio${BOOT0_PIN}/value" sleep 0.1 - echo 1 > ${SYSFSPATH}/gpio${RESET_PIN}/value + echo 1 > "${SYSFSPATH}/gpio${RESET_PIN}/value" } [ -f /proc/device-tree/model ] || die "can't determine hardware version" @@ -113,7 +113,7 @@ case "$1" in else sleep 5 fi - dfu-util -a 0 -D ${FIRMWARE} + dfu-util -a 0 -D "${FIRMWARE}" reset_stm32 ;; --*) usage |