diff --git a/scripts/githelper.sh b/scripts/githelper.sh index 283192d2f13..d914960ed0d 100644 --- a/scripts/githelper.sh +++ b/scripts/githelper.sh @@ -1,3 +1,5 @@ +#!/bin/false +#shellcheck disable=SC1008 # # This is a bash shell fragment, intended to be sourced by scripts that # want to work with git in the emc2 repo. @@ -28,63 +30,71 @@ function githelper() { case $GIT_BRANCH in master) GIT_TAG_GLOB="v2.10.*" + # shellcheck disable=SC2034 DEB_COMPONENT="master" ;; # release branches have names matching "number.number", which is awkward to express as a glob [0-9].[0-9] | [0-9].[0-9][0-9] | [0-9].[0-9][0-9][0-9] | [0-9][0-9].[0-9] | [0-9][0-9].[0-9][0-9] | [0-9][0-9].[0-9][0-9][0-9]) GIT_TAG_GLOB="v${GIT_BRANCH}.*" + # shellcheck disable=SC2034 DEB_COMPONENT=$GIT_BRANCH ;; v2.5_branch) GIT_TAG_GLOB="v2.5*" + # shellcheck disable=SC2034 DEB_COMPONENT="v2.5_branch" ;; v2.4_branch) GIT_TAG_GLOB="v2.4*" + # shellcheck disable=SC2034 DEB_COMPONENT="v2.4_branch" ;; *) GIT_TAG_GLOB="*" + # shellcheck disable=SC2034 DEB_COMPONENT="scratch" ;; esac # use the gnupg keyring from our git repo to verify signatures on the release tags - export GNUPGHOME=$(git rev-parse --show-toplevel)/gnupg + export GNUPGHOME + GNUPGHOME=$(git rev-parse --show-toplevel)/gnupg NEWEST_SIGNED_TAG_UTIME=-1 NEWEST_UNSIGNED_TAG_UTIME=-1 for TAG in $(git tag -l "$GIT_TAG_GLOB"); do - if ! git cat-file tag $TAG > /dev/null 2> /dev/null; then + if ! git cat-file tag "$TAG" > /dev/null 2> /dev/null; then continue fi - TAG_UTIME=$(git cat-file tag $TAG | grep tagger | awk '{print $(NF-1)-$NF*36}') + TAG_UTIME=$(git cat-file tag "$TAG" | grep tagger | awk '{print $(NF-1)-$NF*36}') if git tag -v "$TAG" > /dev/null 2> /dev/null; then # it's a valid signed tag - if [ $TAG_UTIME -gt $NEWEST_SIGNED_TAG_UTIME ]; then - NEWEST_SIGNED_TAG=$TAG - NEWEST_SIGNED_TAG_UTIME=$TAG_UTIME + if [ "$TAG_UTIME" -gt "$NEWEST_SIGNED_TAG_UTIME" ]; then + NEWEST_SIGNED_TAG="$TAG" + NEWEST_SIGNED_TAG_UTIME="$TAG_UTIME" fi else # unsigned tag - if [ $TAG_UTIME -gt $NEWEST_UNSIGNED_TAG_UTIME ]; then - NEWEST_UNSIGNED_TAG=$TAG - NEWEST_UNSIGNED_TAG_UTIME=$TAG_UTIME + if [ "$TAG_UTIME" -gt "$NEWEST_UNSIGNED_TAG_UTIME" ]; then + NEWEST_UNSIGNED_TAG="$TAG" + NEWEST_UNSIGNED_TAG_UTIME="$TAG_UTIME" fi fi done - if [ $NEWEST_SIGNED_TAG_UTIME -gt -1 ]; then + if [ "$NEWEST_SIGNED_TAG_UTIME" -gt -1 ]; then + # shellcheck disable=SC2034 GIT_TAG="$NEWEST_SIGNED_TAG" return fi - if [ $NEWEST_UNSIGNED_TAG_UTIME -gt -1 ]; then + if [ "$NEWEST_UNSIGNED_TAG_UTIME" -gt -1 ]; then echo "no signed tags found, falling back to unsigned tags" > /dev/null 1>&2 + # shellcheck disable=SC2034 GIT_TAG="$NEWEST_UNSIGNED_TAG" return fi diff --git a/tests/build/header-sanity/test.sh b/tests/build/header-sanity/test.sh index 38fbdf6f501..717e7f7c9f9 100755 --- a/tests/build/header-sanity/test.sh +++ b/tests/build/header-sanity/test.sh @@ -1,21 +1,28 @@ #!/bin/sh set -xe CPPFLAGS=$(pkg-config --silence-errors --cflags libtirpc) -for i in $HEADERS/*.h; do + +for i in "$HEADERS"/*.h +do case $i in */rtapi_app.h) continue ;; esac + # shellcheck disable=SC2086 gcc ${CPPFLAGS} -DULAPI -I$HEADERS -E -x c $i > /dev/null done -for i in $HEADERS/*.h $HEADERS/*.hh; do - case $i in + +for i in "$HEADERS"/*.h "$HEADERS"/*.hh +do + case "$i" in */rtapi_app.h) continue ;; */interp_internal.hh) continue ;; esac + # shellcheck disable=SC2086 if g++ ${CPPFLAGS} -std=c++11 -S -o /dev/null -xcxx /dev/null > /dev/null 2>&1; then ELEVEN=-std=c++11 else ELEVEN=-std=c++0x fi - g++ ${CPPFLAGS} $ELEVEN -DULAPI -I$HEADERS -E -x c++ $i > /dev/null + # shellcheck disable=SC2086 + g++ ${CPPFLAGS} $ELEVEN -DULAPI -I$HEADERS -E -x c++ "$i" > /dev/null done diff --git a/tests/ccomp/lathe-comp/test.sh b/tests/ccomp/lathe-comp/test.sh index b631a39327a..f74438f2b88 100644 --- a/tests/ccomp/lathe-comp/test.sh +++ b/tests/ccomp/lathe-comp/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -t test.tbl -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/ccomp/mill-g90g91g92/test.sh b/tests/ccomp/mill-g90g91g92/test.sh index b631a39327a..f74438f2b88 100644 --- a/tests/ccomp/mill-g90g91g92/test.sh +++ b/tests/ccomp/mill-g90g91g92/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -t test.tbl -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/ccomp/mill-line-arc-entry/test.sh b/tests/ccomp/mill-line-arc-entry/test.sh index b631a39327a..f74438f2b88 100644 --- a/tests/ccomp/mill-line-arc-entry/test.sh +++ b/tests/ccomp/mill-line-arc-entry/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -t test.tbl -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/ccomp/mill-zchanges/test.sh b/tests/ccomp/mill-zchanges/test.sh index b631a39327a..f74438f2b88 100644 --- a/tests/ccomp/mill-zchanges/test.sh +++ b/tests/ccomp/mill-zchanges/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -t test.tbl -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/classicladder/estop/test.sh b/tests/classicladder/estop/test.sh index 2affbde136c..fb283a41de4 100755 --- a/tests/classicladder/estop/test.sh +++ b/tests/classicladder/estop/test.sh @@ -7,4 +7,4 @@ if [ "libeatmydata.so" = "$LD_PRELOAD" ] ; then unset LD_PRELOAD fi -exec linuxcnc $(dirname $0)/classicladder-estop.ini +exec linuxcnc "$(dirname "$0")"/classicladder-estop.ini diff --git a/tests/halcompile/names/test.sh b/tests/halcompile/names/test.sh index 5a997bda9fc..a1ae5e9271d 100755 --- a/tests/halcompile/names/test.sh +++ b/tests/halcompile/names/test.sh @@ -3,11 +3,12 @@ set -x # this one must succeed rm -f names_match.c -halcompile names_match.comp -if [ $? -ne 0 ]; then + +if ! halcompile names_match.comp; then echo 'halcompile failed to process names_match.comp' exit 1 fi + if [ ! -f names_match.c ]; then echo 'halcompile failed to produce names_match.c' exit 1 @@ -15,11 +16,12 @@ fi # this one must fail rm -f names_dont_match.c -halcompile names_dont_match.comp -if [ $? -eq 0 ]; then + +if halcompile names_dont_match.comp; then echo 'halcompile erroneously accepted names_dont_match.comp' exit 1 fi + if [ -f names_dont_match.c ]; then echo 'halcompile erroneously produced names_dont_match.c' exit 1 diff --git a/tests/hm2-idrom/test.sh b/tests/hm2-idrom/test.sh index 8930c887f9b..316ca1c3137 100755 --- a/tests/hm2-idrom/test.sh +++ b/tests/hm2-idrom/test.sh @@ -19,11 +19,11 @@ Error[14]="hm2/hm2_test\.0: IDROM IOPorts is 0 but llio num_ioport_connectors is result=0 TEST_PATTERN=0 -while [ ! -z "${Error[$TEST_PATTERN]}" ]; do +while [ -n "${Error[$TEST_PATTERN]}" ]; do export TEST_PATTERN halrun -f broken-load-test.hal >halrun-stdout 2>halrun-stderr ./check-dmesg.py "${Error[$TEST_PATTERN]}" || exit $? - TEST_PATTERN=$(($TEST_PATTERN+1)) + TEST_PATTERN=$((TEST_PATTERN+1)) done exit $result diff --git a/tests/interp/cam-nisley/test.sh b/tests/interp/cam-nisley/test.sh index 3ee34072b1b..4440735bfae 100644 --- a/tests/interp/cam-nisley/test.sh +++ b/tests/interp/cam-nisley/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -t test.tbl -g cam.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/crazy-paths/test.sh b/tests/interp/crazy-paths/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/interp/crazy-paths/test.sh +++ b/tests/interp/crazy-paths/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/do-while-break/test.sh b/tests/interp/do-while-break/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/interp/do-while-break/test.sh +++ b/tests/interp/do-while-break/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/exists/test.sh b/tests/interp/exists/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/interp/exists/test.sh +++ b/tests/interp/exists/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/flowsnake/test.sh b/tests/interp/flowsnake/test.sh index 68e5ed2082f..18893aab433 100644 --- a/tests/interp/flowsnake/test.sh +++ b/tests/interp/flowsnake/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g flowsnake.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/fractional-linenumbers/test.sh b/tests/interp/fractional-linenumbers/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/interp/fractional-linenumbers/test.sh +++ b/tests/interp/fractional-linenumbers/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g10/g10-l1-l10/test.sh b/tests/interp/g10/g10-l1-l10/test.sh index 29ef11d7a75..52077f363e2 100755 --- a/tests/interp/g10/g10-l1-l10/test.sh +++ b/tests/interp/g10/g10-l1-l10/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc -t test.tbl | awk '{$1=""; print}' | sed 's/-0\.0000/0.0000/g' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g10/g10-l11/test.sh b/tests/interp/g10/g10-l11/test.sh index 29ef11d7a75..52077f363e2 100755 --- a/tests/interp/g10/g10-l11/test.sh +++ b/tests/interp/g10/g10-l11/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc -t test.tbl | awk '{$1=""; print}' | sed 's/-0\.0000/0.0000/g' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g10/g10-l2-while-active/test.sh b/tests/interp/g10/g10-l2-while-active/test.sh index 83d69e365c8..2afa80d1ca5 100755 --- a/tests/interp/g10/g10-l2-while-active/test.sh +++ b/tests/interp/g10/g10-l2-while-active/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g10/g10-l20-while-active/test.sh b/tests/interp/g10/g10-l20-while-active/test.sh index 6d4141e75aa..65bddf51a33 100755 --- a/tests/interp/g10/g10-l20-while-active/test.sh +++ b/tests/interp/g10/g10-l20-while-active/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' | sed 's/-0\.0000/0.0000/g' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g10/g10-with-g92/test.sh b/tests/interp/g10/g10-with-g92/test.sh index 8fa0c30ded8..69ec8bee746 100755 --- a/tests/interp/g10/g10-with-g92/test.sh +++ b/tests/interp/g10/g10-with-g92/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc -t test.tbl | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g33.1/test.sh b/tests/interp/g33.1/test.sh index 5a9af07688e..574a4921f8a 100644 --- a/tests/interp/g33.1/test.sh +++ b/tests/interp/g33.1/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g g33.1.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g6164/test.sh b/tests/interp/g6164/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/interp/g6164/test.sh +++ b/tests/interp/g6164/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g71-endless-loop/test.sh b/tests/interp/g71-endless-loop/test.sh index 1bd1a760d80..5394b9f3867 100755 --- a/tests/interp/g71-endless-loop/test.sh +++ b/tests/interp/g71-endless-loop/test.sh @@ -10,14 +10,14 @@ pid=$! # Give it 10 seconds to complete count=10 -while [ 0 -lt $count ] && kill -0 $pid > /dev/null 2>&1 ; do +while [ 0 -lt "$count" ] && kill -0 "$pid" > /dev/null 2>&1 ; do sleep 1 - count=$(($count - 1)) + count=$((count - 1)) done -if kill -0 $pid > /dev/null 2>&1; then - kill -9 $pid - echo "error: g71-endless-loop.ngc program seem to be stuck, killing" +if kill -0 "$pid" > /dev/null 2>&1; then + kill -9 "$pid" + echo "E: g71-endless-loop.ngc program seem to be stuck, killing" exit 1 fi diff --git a/tests/interp/g71-with-g70/test.sh b/tests/interp/g71-with-g70/test.sh index 4b4a415b7f6..c05131005da 100755 --- a/tests/interp/g71-with-g70/test.sh +++ b/tests/interp/g71-with-g70/test.sh @@ -7,13 +7,13 @@ pid=$! # Give it 5 seconds to complete count=5 -while [ 0 -lt $count ] && kill -0 $pid > /dev/null 2>&1 ; do +while [ 0 -lt "$count" ] && kill -0 "$pid" > /dev/null 2>&1 ; do sleep 1 - count=$(($count - 1)) + count=$((count - 1)) done -if kill -0 $pid > /dev/null 2>&1; then - kill -9 $pid +if kill -0 "$pid" > /dev/null 2>&1; then + kill -9 "$pid" echo "error: g71_and_g70.ngc program seem to be stuck, killing" exit 1 fi diff --git a/tests/interp/g72-facing/test.sh b/tests/interp/g72-facing/test.sh index dd1faa09c3d..9a50906825c 100755 --- a/tests/interp/g72-facing/test.sh +++ b/tests/interp/g72-facing/test.sh @@ -8,14 +8,14 @@ pid=$! # Give it 10 seconds to complete count=10 -while [ 0 -lt $count ] && kill -0 $pid > /dev/null 2>&1 ; do +while [ 0 -lt "$count" ] && kill -0 "$pid" > /dev/null 2>&1 ; do sleep 1 - count=$(($count - 1)) + count=$((count - 1)) done -if kill -0 $pid > /dev/null 2>&1; then - kill -9 $pid - echo "error: g71-iterations-present.ngc program seem to be stuck, killing" +if kill -0 "$pid" > /dev/null 2>&1; then + kill -9 "$pid" + echo "E: g71-iterations-present.ngc program seem to be stuck, killing" exit 1 fi diff --git a/tests/interp/g72-missing-iteration/test.sh b/tests/interp/g72-missing-iteration/test.sh index bd67a9bd6e4..acd1d57fec7 100755 --- a/tests/interp/g72-missing-iteration/test.sh +++ b/tests/interp/g72-missing-iteration/test.sh @@ -10,14 +10,14 @@ pid=$! # Give it 10 seconds to complete count=10 -while [ 0 -lt $count ] && kill -0 $pid > /dev/null 2>&1 ; do +while [ 0 -lt "$count" ] && kill -0 "$pid" > /dev/null 2>&1 ; do sleep 1 count=$((count - 1)) done -if kill -0 $pid > /dev/null 2>&1; then - kill -9 $pid - echo "error: g71-iterations-missing.ngc program seem to be stuck, killing" +if kill -0 "$pid" > /dev/null 2>&1; then + kill -9 "$pid" + echo "E: g71-iterations-missing.ngc program seem to be stuck, killing" exit 1 fi diff --git a/tests/interp/g76/test.sh b/tests/interp/g76/test.sh index e5c98955404..1993dcb1c88 100644 --- a/tests/interp/g76/test.sh +++ b/tests/interp/g76/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -t test.tbl -g g76only.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g81/g17/g98/test.sh b/tests/interp/g81/g17/g98/test.sh index 3aa65b53475..214cd02540e 100644 --- a/tests/interp/g81/g17/g98/test.sh +++ b/tests/interp/g81/g17/g98/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g g17-g98-g81.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g81/g17/g99/test.sh b/tests/interp/g81/g17/g99/test.sh index 466c7243a0c..f4f8fec3660 100644 --- a/tests/interp/g81/g17/g99/test.sh +++ b/tests/interp/g81/g17/g99/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g g17-g99-g81.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g81/g18/g98/test.sh b/tests/interp/g81/g18/g98/test.sh index 8828e2e9319..056ffb5014e 100644 --- a/tests/interp/g81/g18/g98/test.sh +++ b/tests/interp/g81/g18/g98/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g g18-g98-g81.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g81/g18/g99/test.sh b/tests/interp/g81/g18/g99/test.sh index 4de0eb0743c..1eba671e2f8 100644 --- a/tests/interp/g81/g18/g99/test.sh +++ b/tests/interp/g81/g18/g99/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g g18-g99-g81.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g81/g19/g98/test.sh b/tests/interp/g81/g19/g98/test.sh index d4f14b95f46..a10d41f6953 100644 --- a/tests/interp/g81/g19/g98/test.sh +++ b/tests/interp/g81/g19/g98/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g g19-g98-g81.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g81/g19/g99/test.sh b/tests/interp/g81/g19/g99/test.sh index 69187669c25..ef2c0ac2ac0 100644 --- a/tests/interp/g81/g19/g99/test.sh +++ b/tests/interp/g81/g19/g99/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g g19-g99-g81.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g84/g17/g98/test.sh b/tests/interp/g84/g17/g98/test.sh index 601e4ada81f..5a43938a92b 100755 --- a/tests/interp/g84/g17/g98/test.sh +++ b/tests/interp/g84/g17/g98/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g g17-g98-g84.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g84/g17/g99/test.sh b/tests/interp/g84/g17/g99/test.sh index ab358fce49a..5b95133f8e3 100644 --- a/tests/interp/g84/g17/g99/test.sh +++ b/tests/interp/g84/g17/g99/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g g17-g99-g84.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g84/g18/g98/test.sh b/tests/interp/g84/g18/g98/test.sh index 9110de97652..0b60af3801d 100644 --- a/tests/interp/g84/g18/g98/test.sh +++ b/tests/interp/g84/g18/g98/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g g18-g98-g84.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g84/g18/g99/test.sh b/tests/interp/g84/g18/g99/test.sh index b7008b70fb0..f946371d20e 100644 --- a/tests/interp/g84/g18/g99/test.sh +++ b/tests/interp/g84/g18/g99/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g g18-g99-g84.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g84/g19/g98/test.sh b/tests/interp/g84/g19/g98/test.sh index 9b0806ee414..4545239caee 100644 --- a/tests/interp/g84/g19/g98/test.sh +++ b/tests/interp/g84/g19/g98/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g g19-g98-g84.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/g84/g19/g99/test.sh b/tests/interp/g84/g19/g99/test.sh index 16e5a42673a..e82c38e1084 100644 --- a/tests/interp/g84/g19/g99/test.sh +++ b/tests/interp/g84/g19/g99/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g g19-g99-g84.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/iniparam-failassign/test.sh b/tests/interp/iniparam-failassign/test.sh index af88e94afae..f15a7afbf8a 100755 --- a/tests/interp/iniparam-failassign/test.sh +++ b/tests/interp/iniparam-failassign/test.sh @@ -1,10 +1,8 @@ #!/bin/bash export PYTHONUNBUFFERED=1 -rs274 -i test.ini -g test.ngc 2>&1 - -# expected to fail -if [ $? -ne 0 ]; then +if ! rs274 -i test.ini -g test.ngc 2>&1 +then + # expected to fail exit 0 fi - exit 1 diff --git a/tests/interp/inside-corners/test.sh b/tests/interp/inside-corners/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/interp/inside-corners/test.sh +++ b/tests/interp/inside-corners/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/inverse-time-with-comp/test.sh b/tests/interp/inverse-time-with-comp/test.sh index 9279a98e2f2..cec720fe1f7 100644 --- a/tests/interp/inverse-time-with-comp/test.sh +++ b/tests/interp/inverse-time-with-comp/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g inverse.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/m19/test.sh b/tests/interp/m19/test.sh index da351514599..22f60fd0ac7 100644 --- a/tests/interp/m19/test.sh +++ b/tests/interp/m19/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -n 0 -i test.ini -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/m98m99/01-basics/test.sh b/tests/interp/m98m99/01-basics/test.sh index 83d69e365c8..2afa80d1ca5 100755 --- a/tests/interp/m98m99/01-basics/test.sh +++ b/tests/interp/m98m99/01-basics/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/m98m99/02-variables/test.sh b/tests/interp/m98m99/02-variables/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/interp/m98m99/02-variables/test.sh +++ b/tests/interp/m98m99/02-variables/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/m98m99/03-error-M98-no-P-word/test.sh b/tests/interp/m98m99/03-error-M98-no-P-word/test.sh index a0d94f6194c..4905af41aa2 100755 --- a/tests/interp/m98m99/03-error-M98-no-P-word/test.sh +++ b/tests/interp/m98m99/03-error-M98-no-P-word/test.sh @@ -1,9 +1,7 @@ #!/bin/bash -rs274 -g test.ngc 2>&1 - -# expected to fail -if [ $? -ne 0 ]; then +if ! rs274 -g test.ngc 2>&1 +then + # expected to fail exit 0 fi - exit 1 diff --git a/tests/interp/m98m99/05-M98-loops/test.sh b/tests/interp/m98m99/05-M98-loops/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/interp/m98m99/05-M98-loops/test.sh +++ b/tests/interp/m98m99/05-M98-loops/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/m98m99/07-nested-subs/test.sh b/tests/interp/m98m99/07-nested-subs/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/interp/m98m99/07-nested-subs/test.sh +++ b/tests/interp/m98m99/07-nested-subs/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/m98m99/08-sub-follows-main/test.sh b/tests/interp/m98m99/08-sub-follows-main/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/interp/m98m99/08-sub-follows-main/test.sh +++ b/tests/interp/m98m99/08-sub-follows-main/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/m98m99/10-M98-P001/test.sh b/tests/interp/m98m99/10-M98-P001/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/interp/m98m99/10-M98-P001/test.sh +++ b/tests/interp/m98m99/10-M98-P001/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/m98m99/11-main-program-oword/test.sh b/tests/interp/m98m99/11-main-program-oword/test.sh index 448dc119130..ce5ae835cd6 100644 --- a/tests/interp/m98m99/11-main-program-oword/test.sh +++ b/tests/interp/m98m99/11-main-program-oword/test.sh @@ -18,8 +18,8 @@ ILLEGAL_TESTS=" # for t in $LEGAL_TESTS; do echo "Legal test ${t}:" - rs274 -g test-legal-${t}.ngc | awk '{$1=""; print}' - res=${PIPESTATUS[0]} + rs274 -g "test-legal-${t}.ngc" | awk '{$1=""; print}' + res="${PIPESTATUS[0]}" if test "$res" = 0; then echo "Success: Test '${t}' exited ${res}" >&2 else @@ -33,8 +33,8 @@ done for t in $ILLEGAL_TESTS; do echo "Illegal test ${t}:" res=-1 - rs274 -g test-illegal-${t}.ngc | awk '{$1=""; print}' - res=${PIPESTATUS[0]} + rs274 -g "test-illegal-${t}.ngc" | awk '{$1=""; print}' + res="${PIPESTATUS[0]}" if test "$res" = 0; then echo "Error: Illegal test '${t}' exited ${res}" >&2 exit "$res" diff --git a/tests/interp/m98m99/12-M99-endless-main-program/test.sh b/tests/interp/m98m99/12-M99-endless-main-program/test.sh index 9a0ef1271f3..7ef57534546 100755 --- a/tests/interp/m98m99/12-M99-endless-main-program/test.sh +++ b/tests/interp/m98m99/12-M99-endless-main-program/test.sh @@ -7,4 +7,4 @@ linuxcnc -r motion-logger.ini # Run test file in stand-alone interpreter: should run program once rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/magic_comments/param_format_printing/test.sh b/tests/interp/magic_comments/param_format_printing/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/interp/magic_comments/param_format_printing/test.sh +++ b/tests/interp/magic_comments/param_format_printing/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/namedparam-bug424/test.sh b/tests/interp/namedparam-bug424/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/interp/namedparam-bug424/test.sh +++ b/tests/interp/namedparam-bug424/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/oword-bug315-p2/test.sh b/tests/interp/oword-bug315-p2/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/interp/oword-bug315-p2/test.sh +++ b/tests/interp/oword-bug315-p2/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/oword-bug315/test.sh b/tests/interp/oword-bug315/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/interp/oword-bug315/test.sh +++ b/tests/interp/oword-bug315/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/oword-unwind/test.sh b/tests/interp/oword-unwind/test.sh index da351514599..22f60fd0ac7 100644 --- a/tests/interp/oword-unwind/test.sh +++ b/tests/interp/oword-unwind/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -n 0 -i test.ini -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/plug/absolute/test.sh b/tests/interp/plug/absolute/test.sh index 7d29952328b..7044c07bf33 100644 --- a/tests/interp/plug/absolute/test.sh +++ b/tests/interp/plug/absolute/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -p "${LIBDIR}"/linuxcnc/canterp.so -g canon | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/plug/filename/test.sh b/tests/interp/plug/filename/test.sh index 40043f9edd3..e6c1a20e9a4 100644 --- a/tests/interp/plug/filename/test.sh +++ b/tests/interp/plug/filename/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -p canterp.so -g canon | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/plug/relative/test.sh b/tests/interp/plug/relative/test.sh index defb33cfdb0..55db7ddb4b5 100644 --- a/tests/interp/plug/relative/test.sh +++ b/tests/interp/plug/relative/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -p ./canterp.so -g canon | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/return-value/test.sh b/tests/interp/return-value/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/interp/return-value/test.sh +++ b/tests/interp/return-value/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/rotation/abs-pts/test.sh b/tests/interp/rotation/abs-pts/test.sh index 5b214441322..53e9013752c 100644 --- a/tests/interp/rotation/abs-pts/test.sh +++ b/tests/interp/rotation/abs-pts/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc -t test.tbl | awk '/MESSAGE/ {$1=""; print}' | sed 's/-0\.0000/0.0000/g' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/rotation/g28/test.sh b/tests/interp/rotation/g28/test.sh index 33218bea6ab..998595ed67e 100755 --- a/tests/interp/rotation/g28/test.sh +++ b/tests/interp/rotation/g28/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g g28.ngc | sed 's/-0\.0000/0.0000/g' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/rotation/g53/test.sh b/tests/interp/rotation/g53/test.sh index ac5b7fe17a5..8ced2f78e4b 100755 --- a/tests/interp/rotation/g53/test.sh +++ b/tests/interp/rotation/g53/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g g53.ngc | sed 's/-0\.0000/0.0000/g' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/interp/subs-follow-main/test.sh b/tests/interp/subs-follow-main/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/interp/subs-follow-main/test.sh +++ b/tests/interp/subs-follow-main/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/linuxcncrsh-tcp/test.sh b/tests/linuxcncrsh-tcp/test.sh index a8da4840ac4..218cff9d9ba 100755 --- a/tests/linuxcncrsh-tcp/test.sh +++ b/tests/linuxcncrsh-tcp/test.sh @@ -12,42 +12,42 @@ linuxcnc -r linuxcncrsh-test.ini & # let linuxcnc come up TOGO=80 -while [ $TOGO -gt 0 ]; do +while [ "$TOGO" -gt 0 ]; do echo trying to connect to linuxcncrsh TOGO=$TOGO if nc -z localhost 5007; then break fi sleep 0.25 - TOGO=$(($TOGO - 1)) + TOGO=$((TOGO - 1)) done -if [ $TOGO -eq 0 ]; then - echo connection to linuxcncrsh timed out +if [ "$TOGO" -eq 0 ]; then + echo "connection to linuxcncrsh timed out" exit 1 fi ( - echo hello EMC mt 1.0 - echo set enable EMCTOO + echo "hello EMC mt 1.0" + echo "set enable EMCTOO" # ask linuxcncrsh to not read the next command until it's done running # the current one - echo set set_wait done + echo "set set_wait done" - echo set mode manual - echo set estop off - echo set machine on + echo "set mode manual" + echo "set estop off" + echo "set machine on" - echo set mode mdi - echo set mdi m100 p-1 q-2 + echo "set mode mdi" + echo "set mdi m100 p-1 q-2" sleep 1 # here comes a big blob dd bs=4096 if=lots-of-gcode - echo set mdi m100 p-3 q-4 + echo "set mdi m100 p-3 q-4" - echo shutdown + echo "shutdown" ) | nc localhost 5007 diff --git a/tests/lowlevel/mutex/test.sh b/tests/lowlevel/mutex/test.sh index 9c6afff1754..f4eb03c34b8 100755 --- a/tests/lowlevel/mutex/test.sh +++ b/tests/lowlevel/mutex/test.sh @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=SC2086 gcc -O -I${HEADERS} test.c -o test -DULAPI -std=gnu99 -pthread || exit 1 ./test; exitval=$? rm -f test diff --git a/tests/m70-m73/m70m72-restore.0/test.sh b/tests/m70-m73/m70m72-restore.0/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/m70-m73/m70m72-restore.0/test.sh +++ b/tests/m70-m73/m70m72-restore.0/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/m70-m73/m73-flood-mist-restore.0/test.sh b/tests/m70-m73/m73-flood-mist-restore.0/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/m70-m73/m73-flood-mist-restore.0/test.sh +++ b/tests/m70-m73/m73-flood-mist-restore.0/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/m70-m73/m73autorestore.0/test.sh b/tests/m70-m73/m73autorestore.0/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/m70-m73/m73autorestore.0/test.sh +++ b/tests/m70-m73/m73autorestore.0/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/mdi-queue/oword-queue-buster/test.sh b/tests/mdi-queue/oword-queue-buster/test.sh index b52b2bac433..344b03d0450 100755 --- a/tests/mdi-queue/oword-queue-buster/test.sh +++ b/tests/mdi-queue/oword-queue-buster/test.sh @@ -28,9 +28,9 @@ while [ $TOGO -gt 0 ]; do break fi sleep 0.25 - TOGO=$(($TOGO - 1)) + TOGO=$((TOGO - 1)) done -if [ $TOGO -eq 0 ]; then +if [ "$TOGO" -eq 0 ]; then echo "E: connection to linuxcncrsh timed out" exit 1 fi @@ -42,12 +42,13 @@ NUM_MDIS=1 NUM_MDIS_LEFT=$NUM_MDIS TOOL=1 for i in $(seq 0 1000); do - NUM_MDIS_LEFT=$(($NUM_MDIS_LEFT - 1)) + NUM_MDIS_LEFT=$((NUM_MDIS_LEFT - 1)) if [ $NUM_MDIS_LEFT -eq 0 ]; then echo "set mdi o call [$TOOL]" >> lots-of-gcode + # shellcheck disable=SC2129 echo "P is 12345.000000" >> expected-gcode-output - echo "P is $((-1 * $TOOL)).000000" >> expected-gcode-output - echo "P is 54321.000000" >> expected-gcode-output + echo "P is $((-1 * TOOL)).000000" >> expected-gcode-output + echo "P is 54321.000000" >> expected-gcode-output if [ $TOOL -eq 1 ]; then TOOL=2 @@ -55,8 +56,8 @@ for i in $(seq 0 1000); do TOOL=1 fi - NUM_MDIS=$(($NUM_MDIS + 1)) - if [ $NUM_MDIS -gt 10 ]; then + NUM_MDIS=$((NUM_MDIS + 1)) + if [ "$NUM_MDIS" -gt 10 ]; then NUM_MDIS=1 fi @@ -68,27 +69,27 @@ done echo "P is -200.000000" >> expected-gcode-output ( - echo hello EMC mt 1.0 - echo set enable EMCTOO + echo "hello EMC mt 1.0" + echo "set enable EMCTOO" - echo set mode manual - echo set estop off - echo set machine on + echo "set mode manual" + echo "set estop off" + echo "set machine on" - echo set mode auto - echo set open dummy.ngc + echo "set mode auto" + echo "set open dummy.ngc" - echo set mode mdi - echo set mdi m100 p-100 - echo set wait done + echo "set mode mdi" + echo "set mdi m100 p-100" + echo "set wait done" # here comes a big blob dd bs=4096 if=lots-of-gcode - echo set mdi m100 p-200 - echo set wait done + echo "set mdi m100 p-200" + echo "set wait done" - echo shutdown + echo "shutdown" ) | nc localhost 5007 diff --git a/tests/mdi-queue/simple-queue-buster/test.sh b/tests/mdi-queue/simple-queue-buster/test.sh index 41dfcc604a0..aaa77135bca 100755 --- a/tests/mdi-queue/simple-queue-buster/test.sh +++ b/tests/mdi-queue/simple-queue-buster/test.sh @@ -28,7 +28,7 @@ while [ $TOGO -gt 0 ]; do break fi sleep 0.25 - TOGO=$(($TOGO - 1)) + TOGO=$((TOGO - 1)) done if [ $TOGO -eq 0 ]; then echo connection to linuxcncrsh timed out @@ -42,8 +42,8 @@ NUM_MDIS=1 NUM_MDIS_LEFT=$NUM_MDIS TOOL=1 for i in $(seq 0 1000); do - NUM_MDIS_LEFT=$(($NUM_MDIS_LEFT - 1)) - if [ $NUM_MDIS_LEFT -eq 0 ]; then + NUM_MDIS_LEFT=$((NUM_MDIS_LEFT - 1)) + if [ "$NUM_MDIS_LEFT" -eq 0 ]; then echo "set mdi t$TOOL m6" >> lots-of-gcode if [ $TOOL -eq 1 ]; then TOOL=2 @@ -51,8 +51,8 @@ for i in $(seq 0 1000); do TOOL=1 fi - NUM_MDIS=$(($NUM_MDIS + 1)) - if [ $NUM_MDIS -gt 10 ]; then + NUM_MDIS=$((NUM_MDIS + 1)) + if [ "$NUM_MDIS" -gt 10 ]; then NUM_MDIS=1 fi @@ -64,28 +64,28 @@ done echo "P is -2.000000" >> expected-gcode-output ( - echo hello EMC mt 1.0 - echo set enable EMCTOO + echo "hello EMC mt 1.0" + echo "set enable EMCTOO" # ask linuxcncrsh to not read the next command until it's done running # the current one - #echo set set_wait done + #echo "set set_wait done" - echo set mode manual - echo set estop off - echo set machine on + echo "set mode manual" + echo "set estop off" + echo "set machine on" - echo set mode mdi - echo set mdi m100 p-1 - echo set wait done + echo "set mode mdi" + echo "set mdi m100 p-1" + echo "set wait done" # here comes a big blob dd bs=4096 if=lots-of-gcode - echo set mdi m100 p-2 - echo set wait done + echo "set mdi m100 p-2" + echo "set wait done" - echo shutdown + echo "shutdown" ) | nc localhost 5007 diff --git a/tests/mdi-while-queuebuster-waitflag/test.sh b/tests/mdi-while-queuebuster-waitflag/test.sh index c010db9322e..dd204d29e10 100755 --- a/tests/mdi-while-queuebuster-waitflag/test.sh +++ b/tests/mdi-while-queuebuster-waitflag/test.sh @@ -1,8 +1,10 @@ #!/bin/bash -e -for i in `seq 20`; do +# shellcheck disable=SC2034 +for i in $(seq 20) +do linuxcnc -r test.ini if grep -q '^[^+].*Segmentation fault' stderr; then - exit 1 + exit 1 fi done diff --git a/tests/module-loading/shared-test.sh b/tests/module-loading/shared-test.sh index 4f5780138b4..645fedb7b09 100644 --- a/tests/module-loading/shared-test.sh +++ b/tests/module-loading/shared-test.sh @@ -3,13 +3,14 @@ halrun setup.hal > hal-output 2>&1 RESULT=$? -NUM_PINS=$(cat hal-output | grep -E $(cat PIN_NAME_REGEX) | wc -l) +# grep -c counts number of matches +NUM_PINS=$(grep -E -c "$(cat PIN_NAME_REGEX)" hal-output) -if [ $RESULT -ne $(cat RESULT) ]; then +if [ "$RESULT" -ne "$(cat RESULT)" ]; then exit 1 fi -if [ "$NUM_PINS" -ne $(cat NUM_PINS) ]; then +if [ "$NUM_PINS" -ne "$(cat NUM_PINS)" ]; then exit 1 fi diff --git a/tests/motion/g0/test.sh b/tests/motion/g0/test.sh index b54482c459d..9d9de2bb432 100755 --- a/tests/motion/g0/test.sh +++ b/tests/motion/g0/test.sh @@ -7,15 +7,15 @@ wait_for_pin() { pin="$1" value="$2" maxwait=10 # seconds - while [ 0 -lt $maxwait ] \ - && [ "$value" != "$(halcmd -s show pin $pin | awk '{print $4}')" ]; do + while [ 0 -lt "$maxwait" ] \ + && [ "$value" != "$(halcmd -s show pin "$pin" | awk '{print $4}')" ]; do sleep 1 - maxwait=$(($maxwait -1)) + maxwait=$((maxwait - 1)) done - if [ 0 -eq $maxwait ] ; then - echo "error: waiting for pin $pin timed out" - kill $linuxcncpid - kill $samplerpid + if [ 0 -eq "$maxwait" ] ; then + echo "error: waiting for pin '$pin' timed out" + kill "$linuxcncpid" + kill "$samplerpid" exit 1 fi } @@ -25,47 +25,47 @@ linuxcncpid=$! # let linuxcnc come up TOGO=80 -while [ $TOGO -gt 0 ]; do - echo trying to connect to linuxcncrsh TOGO=$TOGO +while [ "$TOGO" -gt 0 ]; do + echo "I: trying to connect to linuxcncrsh TOGO=$TOGO" if nc -z localhost 5007; then break fi sleep 0.25 - TOGO=$(($TOGO - 1)) + TOGO=$((TOGO - 1)) done -if [ $TOGO -eq 0 ]; then - echo connection to linuxcncrsh timed out +if [ "$TOGO" -eq 0 ]; then + echo "E: connection to linuxcncrsh timed out" exit 1 fi wait_for_pin motion.in-position TRUE -echo starting to capture data +echo "I: starting to capture data" halsampler -t >| result.halsamples & samplerpid=$! ( - echo hello EMC mt 1.0 - echo set enable EMCTOO + echo "hello EMC mt 1.0" + echo "set enable EMCTOO" - echo set estop off - echo set machine on + echo "set estop off" + echo "set machine on" - echo set mode mdi + echo "set mode mdi" dist=1 - echo set mdi g0x$dist + echo "set mdi g0x$dist" # Wait for movement to complete wait_for_pin joint.0.pos-fb $dist wait_for_pin joint.0.in-position TRUE wait_for_pin joint.1.in-position TRUE - echo shutdown + echo "shutdown" ) | nc localhost 5007 kill $samplerpid wait $samplerpid -echo finished capturing data +echo "I: finished capturing data" # wait for linuxcnc to finish wait $linuxcncpid diff --git a/tests/overrun/test.sh b/tests/overrun/test.sh index 1ef9372048f..a5fbe0ac39a 100755 --- a/tests/overrun/test.sh +++ b/tests/overrun/test.sh @@ -1,8 +1,9 @@ #!/bin/sh -TMPDIR=`mktemp -d /tmp/overrun.XXXXXX` -trap "rm -rf $TMPDIR" 0 1 2 3 9 15 +TMPDIR=$(mktemp -d /tmp/overrun.XXXXXX) +trap "rm -rf '$TMPDIR'" 0 1 2 3 15 +# not trapping 9 since it cannot be trapped -TEST_HAL=$TMPDIR/test.hal -echo loadusr -w echo overrun > $TMPDIR/test.hal +TEST_HAL="$TMPDIR"/test.hal +echo loadusr -w echo overrun > "$TMPDIR"/test.hal -! $RUNTESTS $TMPDIR 2>&1 +! $RUNTESTS "$TMPDIR" 2>&1 diff --git a/tests/oword/sub.0/test.sh b/tests/oword/sub.0/test.sh index 83d69e365c8..2afa80d1ca5 100644 --- a/tests/oword/sub.0/test.sh +++ b/tests/oword/sub.0/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/oword/while.0/test.sh b/tests/oword/while.0/test.sh index 83d69e365c8..2afa80d1ca5 100755 --- a/tests/oword/while.0/test.sh +++ b/tests/oword/while.0/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/remap/duplicate-o-word/test.sh b/tests/remap/duplicate-o-word/test.sh index 13adf7d5cf6..99269de600c 100755 --- a/tests/remap/duplicate-o-word/test.sh +++ b/tests/remap/duplicate-o-word/test.sh @@ -1,4 +1,4 @@ #!/bin/bash export INI_FILE_NAME=test.ini -rs274 -i $INI_FILE_NAME -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +rs274 -i "$INI_FILE_NAME" -g test.ngc | awk '{$1=""; print}' +exit "${PIPESTATUS[0]}" diff --git a/tests/remap/fail/args.0/test.sh b/tests/remap/fail/args.0/test.sh index 65d4d349dfe..bb2a78ea3d5 100755 --- a/tests/remap/fail/args.0/test.sh +++ b/tests/remap/fail/args.0/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -i test.ini -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/remap/fail/args.1/test.sh b/tests/remap/fail/args.1/test.sh index 77a112a15ca..974f6975c31 100755 --- a/tests/remap/fail/args.1/test.sh +++ b/tests/remap/fail/args.1/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -i test.ini -n 0 -g test.ngc 2>&1 -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/remap/fail/args.2/test.sh b/tests/remap/fail/args.2/test.sh index 77a112a15ca..974f6975c31 100755 --- a/tests/remap/fail/args.2/test.sh +++ b/tests/remap/fail/args.2/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -i test.ini -n 0 -g test.ngc 2>&1 -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/remap/fail/body-ngc/test.sh b/tests/remap/fail/body-ngc/test.sh index 77a112a15ca..974f6975c31 100755 --- a/tests/remap/fail/body-ngc/test.sh +++ b/tests/remap/fail/body-ngc/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -i test.ini -n 0 -g test.ngc 2>&1 -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/remap/m30-interaction/test.sh b/tests/remap/m30-interaction/test.sh index 57e28aba8d2..a3af97b0369 100755 --- a/tests/remap/m30-interaction/test.sh +++ b/tests/remap/m30-interaction/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -i test.ini -g test.ngc 2>&1 | sed 's/^ *[0-9]* //' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/remap/nested-remaps-oword/test.sh b/tests/remap/nested-remaps-oword/test.sh index 21d662fe18f..57cd866be11 100755 --- a/tests/remap/nested-remaps-oword/test.sh +++ b/tests/remap/nested-remaps-oword/test.sh @@ -1,4 +1,4 @@ #!/bin/bash rs274 -i test.ini -g test.ngc 2>&1 | sed 's/^ *[0-9]* //' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/remap/posargs.0/test.sh b/tests/remap/posargs.0/test.sh index 087b90d47b6..c4f19fb4f54 100755 --- a/tests/remap/posargs.0/test.sh +++ b/tests/remap/posargs.0/test.sh @@ -1,3 +1,3 @@ #!/bin/bash rs274 -i test.ini -n 0 -g test.ngc| awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/remap/remap-reentry/test.sh b/tests/remap/remap-reentry/test.sh index 02f782fcdd5..2e101d82b63 100755 --- a/tests/remap/remap-reentry/test.sh +++ b/tests/remap/remap-reentry/test.sh @@ -1,3 +1,3 @@ #!/bin/bash -e rs274 -g -i test.ini test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/remap/sequencing/test.sh b/tests/remap/sequencing/test.sh index 13adf7d5cf6..37a5e36f0a5 100755 --- a/tests/remap/sequencing/test.sh +++ b/tests/remap/sequencing/test.sh @@ -1,4 +1,4 @@ #!/bin/bash export INI_FILE_NAME=test.ini rs274 -i $INI_FILE_NAME -g test.ngc | awk '{$1=""; print}' -exit ${PIPESTATUS[0]} +exit "${PIPESTATUS[0]}" diff --git a/tests/t0/shared-test.sh b/tests/t0/shared-test.sh index c2f4b67176b..f0cd5293fe5 100644 --- a/tests/t0/shared-test.sh +++ b/tests/t0/shared-test.sh @@ -25,7 +25,7 @@ while [ $TOGO -gt 0 ]; do break fi sleep 0.25 - TOGO=$(($TOGO - 1)) + TOGO=$((TOGO - 1)) done if [ $TOGO -eq 0 ]; then echo connection to linuxcncrsh timed out diff --git a/tests/toolchanger/toolno-pocket-differ/shared-test.sh b/tests/toolchanger/toolno-pocket-differ/shared-test.sh index 34426e36e4c..4981d739255 100755 --- a/tests/toolchanger/toolno-pocket-differ/shared-test.sh +++ b/tests/toolchanger/toolno-pocket-differ/shared-test.sh @@ -19,13 +19,13 @@ linuxcnc -r sim.ini & # let linuxcnc come up TOGO=80 -while [ $TOGO -gt 0 ]; do +while [ "$TOGO" -gt 0 ]; do echo trying to connect to linuxcncrsh TOGO=$TOGO if nc -z localhost 5007; then break fi sleep 0.25 - TOGO=$(($TOGO - 1)) + TOGO=$((TOGO - 1)) done if [ $TOGO -eq 0 ]; then echo connection to linuxcncrsh timed out @@ -37,123 +37,118 @@ fi function introspect() { SEQUENCE_NUMBER=$1 echo "set mdi m100 P6 Q$SEQUENCE_NUMBER" # sequence number - echo 'set mdi m100 P0 Q#5420' # X - echo 'set mdi m100 P1 Q#5421' # Y - echo 'set mdi m100 P2 Q#5422' # Z - echo 'set mdi m100 P3 Q#5400' # toolno - echo 'set mdi m100 P4 Q#5403' # TLO z - echo 'set mdi m100 P5' # blank line + echo "set mdi m100 P0 Q#5420" # X + echo "set mdi m100 P1 Q#5421" # Y + echo "set mdi m100 P2 Q#5422" # Z + echo "set mdi m100 P3 Q#5400" # toolno + echo "set mdi m100 P4 Q#5403" # TLO z + echo "set mdi m100 P5" # blank line } - echo hello EMC mt 1.0 - echo set enable EMCTOO + echo "hello EMC mt 1.0" + echo "set enable EMCTOO" - echo set estop off - echo set machine on - echo set mode mdi + echo "set estop off" + echo "set machine on" + echo "set mode mdi" introspect 0 - echo set mdi t1 m6 + echo "set mdi t1 m6" introspect 1 - echo set mdi g43 + echo "set mdi g43" introspect 2 - echo set mdi g10 l10 p1 z.1 + echo "set mdi g10 l10 p1 z.1" introspect 3 - echo set mdi g43 + echo "set mdi g43" introspect 4 - echo set mdi g10 l10 p10 z.15 + echo "set mdi g10 l10 p10 z.15" introspect 5 - echo set mdi g43 + echo "set mdi g43" introspect 6 - echo set mdi g10 l10 p99999 z.2 + echo "set mdi g10 l10 p99999 z.2" introspect 7 - echo set mdi g43 + echo "set mdi g43" introspect 8 - - echo set mdi t10 m6 + echo "set mdi t10 m6" introspect 9 - echo set mdi g43 + echo "set mdi g43" introspect 10 - echo set mdi g10 l10 p1 z.103 + echo "set mdi g10 l10 p1 z.103" introspect 11 - echo set mdi g43 + echo "set mdi g43" introspect 12 - echo set mdi g10 l10 p10 z.1035 + echo "set mdi g10 l10 p10 z.1035" introspect 13 - echo set mdi g43 + echo "set mdi g43" introspect 14 - echo set mdi g10 l10 p99999 z.104 + echo "set mdi g10 l10 p99999 z.104" introspect 15 - echo set mdi g43 + echo "set mdi g43" introspect 16 - - echo set mdi t99999 m6 + echo "set mdi t99999 m6" introspect 17 - echo set mdi g43 + echo "set mdi g43" introspect 18 - echo set mdi g10 l10 p1 z.3 + echo "set mdi g10 l10 p1 z.3" introspect 19 - echo set mdi g43 + echo "set mdi g43" introspect 20 - echo set mdi g10 l10 p10 z.35 + echo "set mdi g10 l10 p10 z.35" introspect 21 - echo set mdi g43 + echo "set mdi g43" introspect 22 - echo set mdi g10 l10 p99999 z.4 + echo "set mdi g10 l10 p99999 z.4" introspect 23 - echo set mdi g43 + echo "set mdi g43" introspect 24 - - echo set mdi t1 m6 + echo "set mdi t1 m6" introspect 25 - echo set mdi g43 + echo "set mdi g43" introspect 26 - - echo set mdi t10 m6 + echo "set mdi t10 m6" introspect 27 - echo set mdi g43 + echo "set mdi g43" introspect 28 - - echo set mdi t99999 m6 + echo "set mdi t99999 m6" introspect 29 - echo set mdi g43 + echo "set mdi g43" introspect 30 # wait for linuxcnc to finish - echo set wait done + echo "set wait done" - echo shutdown + echo "shutdown" ) | nc localhost 5007 diff --git a/tests/tooledit/test.sh b/tests/tooledit/test.sh index bf8ef83a6b5..461d488138b 100755 --- a/tests/tooledit/test.sh +++ b/tests/tooledit/test.sh @@ -1,8 +1,9 @@ #!/bin/bash + # test if floating point numbers are formatted correctly if ! command -v xvfb-run &> /dev/null; then - echo "xvfb-run could not be found, we assume everything works" > /dev/stderr + echo "W: xvfb-run could not be found, we assume everything works" > /dev/stderr cat expected exit 0 fi @@ -11,20 +12,20 @@ fi #create temporary files so we don't write into write access problems infile=$(mktemp) outfile=$(mktemp) -cat test.tbl > $infile +cat test.tbl > "$infile" # run the test -xvfb-run ${LINUXCNC_EMCSH/wish/tclsh} test.tcl $infile $outfile 2> tclerror.log; +xvfb-run "${LINUXCNC_EMCSH/wish/tclsh}" test.tcl "$infile" "$outfile" 2> tclerror.log -if [ $(cat tclerror.log | wc -l) -ne 0 ]; then +if [ "$(wc -l tclerror.log)" -ne 0 ]; then cat tclerror.log exit 1 fi # write the resulting tool table to stdout so the test framework can evaluate it -cat $outfile +cat "$outfile" # remove the temporary files -rm $infile $outfile $outfile".bak" +rm "$infile" "$outfile" "$outfile.bak" exit 0 diff --git a/tests/trajectory-planner/circular-arcs/test-lengths.sh b/tests/trajectory-planner/circular-arcs/test-lengths.sh index 893f1e01baa..7611afd25d8 100755 --- a/tests/trajectory-planner/circular-arcs/test-lengths.sh +++ b/tests/trajectory-planner/circular-arcs/test-lengths.sh @@ -2,8 +2,8 @@ set -o monitor ./build-debug.sh cp position.blank position.txt -linuxcnc $1 > test.log & -./machine_setup.py $2 +linuxcnc "$1" > test.log & +./machine_setup.py "$2" fg ./save_lengths.sh test.log #if [ -a length_data.log ] diff --git a/tests/trajectory-planner/circular-arcs/test-optimization.sh b/tests/trajectory-planner/circular-arcs/test-optimization.sh index 57fddb45908..5e54c970aaf 100755 --- a/tests/trajectory-planner/circular-arcs/test-optimization.sh +++ b/tests/trajectory-planner/circular-arcs/test-optimization.sh @@ -13,4 +13,4 @@ linuxcnc -r circular_arcs.ini > test.log & ./machine_setup.py "$1" && say_done fg ./save_activate.sh test.log -exit $1 +exit "$1" diff --git a/tests/trajectory-planner/circular-arcs/util/save_vel.sh b/tests/trajectory-planner/circular-arcs/util/save_vel.sh index 16d43718ee5..48f10e31b6b 100755 --- a/tests/trajectory-planner/circular-arcs/util/save_vel.sh +++ b/tests/trajectory-planner/circular-arcs/util/save_vel.sh @@ -1,7 +1,7 @@ #!/bin/bash set -o nounset # Treat unset variables as an error -if [ -a $1 ] +if [ -a "$1" ] then - awk '/tc state/ {print $5,$8,$11}' $1 > vel_data.log + awk '/tc state/ {print $5,$8,$11}' "$1" > vel_data.log fi