Skip to content

Commit

Permalink
Deal with trivial shellcheck problems by using double quotes.
Browse files Browse the repository at this point in the history
  • Loading branch information
BsAtHome committed Jan 30, 2025
1 parent 1c72d4b commit 6ce09eb
Show file tree
Hide file tree
Showing 117 changed files with 417 additions and 406 deletions.
4 changes: 2 additions & 2 deletions bin/profile_axis
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
SCRIPT_LOCATION=$(dirname $(readlink -f $0))
python3 -mcProfile -o axis.profile $SCRIPT_LOCATION/axis "$@"
SCRIPT_LOCATION=$(dirname "$(readlink -f "$0")")
python3 -mcProfile -o axis.profile "$SCRIPT_LOCATION"/axis "$@"
(echo sort cumulative; echo stats 20) | python3 -mpstats axis.profile
4 changes: 2 additions & 2 deletions debian/configure
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ EOF

cd "${0%/*}"

if [ "$1" == "-h" -o "$1" == "-help" -o "$1" == "--help" ]; then
if [ "$1" == "-h" ] || [ "$1" == "-help" ] || [ "$1" == "--help" ]; then
usage
exit 0
fi
Expand Down Expand Up @@ -168,7 +168,7 @@ sed \
-e "s|@YAPPS_RUNTIME@|$YAPPS_RUNTIME|g" \
-e "s#@ENABLE_BUILD_DOCUMENTATION@#$ENABLE_BUILD_DOCUMENTATION#g" \
-e '/^\s*,\s*$/d' \
$*
"$@"
}

if [[ -z "${COMPAT}" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion debian/tests/linuxcnc-test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

set -e

cd $(dirname $0)
cd "$(dirname "$0")"

if ! linuxcnc -r linuxcnc-test.ini ; then
echo "error: failed to execute linuxcnc"
Expand Down
8 changes: 4 additions & 4 deletions debian/tests/rs274-test
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

set -e

cd $(dirname $0)
cd "$(dirname "$0")"

log=$AUTOPKGTEST_TMP/rs274.out

if ! rs274 -g rs274.ngc > $log 2>&1 ; then
if ! rs274 -g rs274.ngc > "$log" 2>&1 ; then
echo "error: failed to run rs274"
cat $log
cat "$log"
exit 1
fi

if ! diff -u $log rs274.res ; then
if ! diff -u "$log" rs274.res ; then
echo "error: rs274 output do not match rs274.res"
exit 1
fi
Expand Down
6 changes: 3 additions & 3 deletions nc_files/M101
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
P=$1
Q=$2

MCMD=$(readlink -nf $0) ;# canonical file name
MNAME=$(basename $MCMD)
MCMD=$(readlink -nf "$0")
MNAME=$(basename "$MCMD")

echo
echo "Example for User M-code invocation:"
Expand All @@ -19,4 +19,4 @@ echo "$MNAME P$P Q$Q"

# if a M1nn command exits with nonzero status,
# the G-code program exits. So always exit 0.
exit 0 ;# 0 for success
exit 0
10 changes: 5 additions & 5 deletions scripts/get-deb-component-from-git
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash

if [ ! -z "$EMC2_HOME" ]; then
source $EMC2_HOME/scripts/githelper.sh
if [ -n "$EMC2_HOME" ]; then
source "$EMC2_HOME"/scripts/githelper.sh
else
source $(git rev-parse --show-toplevel)/scripts/githelper.sh
source "$(git rev-parse --show-toplevel)"/scripts/githelper.sh
fi

githelper $1
githelper "$1"

echo $DEB_COMPONENT
echo "$DEB_COMPONENT"

10 changes: 5 additions & 5 deletions scripts/get-version-from-git
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/bin/bash

if [ ! -z "$EMC2_HOME" ]; then
source $EMC2_HOME/scripts/githelper.sh
if [ -n "$EMC2_HOME" ]; then
source "$EMC2_HOME"/scripts/githelper.sh
else
source $(git rev-parse --show-toplevel)/scripts/githelper.sh
source "$(git rev-parse --show-toplevel)"/scripts/githelper.sh
fi

githelper $1
githelper "$1"

if [ "$DEB_COMPONENT" = "scratch" ]; then
# unknown branches get the VERSION file, plus the branch name (with any
# characters that are invalid in debian version numbers replaced with
# dashes '-'), plus the HEAD commit SHA1
echo v$(git show HEAD:VERSION | cut -d ' ' -f 1)~${GIT_BRANCH//[^-.+:~a-z0-9]/-}~$(git show --pretty=format:%h HEAD | head -1)
echo "v$(git show HEAD:VERSION | cut -d ' ' -f 1)~${GIT_BRANCH//[^-.+:~a-z0-9]/-}~$(git show --pretty=format:%h HEAD | head -1)"
else
# known branches get the "describe" of the most recent signed git tag,
# or of the most recent unsigned tag if no signed tags are found
Expand Down
22 changes: 15 additions & 7 deletions scripts/githelper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# Sets GIT_TAG to the most recent signed tag (this will fall back to the
# most recent tag of any kind if no signed tag is found).
#
# shellcheck shell=bash


function githelper() {
Expand Down Expand Up @@ -45,46 +46,53 @@ function githelper() {
;;
*)
GIT_TAG_GLOB="*"
# Disable unused variable warnings on DEB_COMPONENT
# 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
GNUPGHOME=$(git rev-parse --show-toplevel)/gnupg
export GNUPGHOME

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
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
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
# Disable unused variable warnings on GIT_TAG
# 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
# Disable unused variable warnings on GIT_TAG
# shellcheck disable=SC2034
GIT_TAG="$NEWEST_UNSIGNED_TAG"
return
fi
Expand Down
12 changes: 6 additions & 6 deletions scripts/gladevcp_demo
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

prog=$(basename $0)
prog=$(basename "$0")

function usage () {
cat <<EOF
Expand Down Expand Up @@ -57,7 +57,7 @@ EOF
REALTIME=$(linuxcnc_var REALTIME)
$REALTIME status >/dev/null
status=$?
if [ $status = 0 ] ; then
if [ "$status" = 0 ] ; then
msg="$prog: Realtime is already active"
echo "$msg"
popup "$msg"
Expand All @@ -71,10 +71,10 @@ case $# in
*) ARGS="$@";;
esac

if [ ! -z "$debug" ] ; then
echo debug=$debug
echo REALTIME=$REALTIME
echo ARGS="$ARGS"
if [ -n "$debug" ] ; then
echo "debug=$debug"
echo "REALTIME=$REALTIME"
echo "ARGS=$ARGS"
pwd
fi

Expand Down
12 changes: 6 additions & 6 deletions scripts/halrun.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

PATH=@EMC2_BIN_DIR@:$PATH
REALTIME=@REALTIME@
THIS=$(basename $0)
THIS=$(basename "$0")

export HAL_RTMOD_DIR=@EMC2_RTLIB_DIR@

Expand Down Expand Up @@ -60,7 +60,7 @@ while getopts "ef:hi:kqsvIRQTUV" opt ; do
exit 1;;
esac
done
shift $(($OPTIND - 1))
shift $((OPTIND - 1))

if [ $# -gt 1 ] ; then
echo "$THIS: too many arguments <$*>"
Expand Down Expand Up @@ -150,17 +150,17 @@ if $HAVEFILE ; then
halcmd_twopass "$filename"; result=$?
fi
elif $IS_HALTCL; then
haltcl $@; result=$?
haltcl "$@"; result=$?
else
halcmd $@; result=$?
halcmd "$@"; result=$?
fi
fi

if [ ! -z "$INTERACTIVE" ]; then $INTERACTIVE; fi
if [ -n "$INTERACTIVE" ]; then $INTERACTIVE; fi

halcmd stop || result=$?
halcmd unload all || result=$?

$REALTIME stop || result=$?

exit $result
exit "$result"
94 changes: 47 additions & 47 deletions scripts/linuxcnc_info.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

ofile=/tmp/linuxcnc_info.txt
PROG=$(basename $0)
PROG=$(basename "$0")

usage () {
cat <<EOF
Expand All @@ -36,11 +36,11 @@ exit 1
}

git_commit () {
dir=$(dirname $0)
dir=$(dirname "$0")
if [ "${dir}" = "/usr/bin" ] ; then
echo NA
else
echo $(cd $dir; git rev-parse --short HEAD 2>/dev/null)
echo "$(cd "$dir" && git rev-parse --short HEAD 2>/dev/null)"
fi
}

Expand All @@ -49,7 +49,7 @@ git_commit () {
editors="$VISUAL gedit mousepad geany nedit nano gvim abiword"
VIEWER=""
for e in $editors ; do
if [ -x "$(command -v $e)" ] ; then
if [ -x "$(command -v "$e")" ] ; then
VIEWER=$e
break #use first editor found
fi
Expand Down Expand Up @@ -81,7 +81,7 @@ function show () {
}

function parse_cpuinfo () {
cat /proc/cpuinfo|grep "$1"|head -1|cut -d: -f2-
grep "$1" < /proc/cpuinfo | head -1 | cut -d: -f2-
}

function parse_after_colon () {
Expand Down Expand Up @@ -111,58 +111,58 @@ system and configuration.
EOF

[ -n "$VIEWER" ] && echo VIEWER=$VIEWER

show " Date" $(date)
show " UTC Date" $(date -u)
show " this program" $0
show " uptime" $(uptime)
show " lsb_release -sa" $(lsb_release -sa 2>/dev/null)
show " linuxcnc" $(command -v linuxcnc)
show " pwd" $(pwd -P)
show " USER" $USER
show " LOGNAME" $LOGNAME
show " HOME" $HOME
show " EDITOR" $EDITOR
show " VISUAL" $VISUAL
show " LANGUAGE" $LANGUAGE
show " TERM" $TERM
show " COLORTERM" $COLORTERM
show " DISPLAY" $DISPLAY
show " DESKTOP" $DESKTOP_SESSION
show " display size" $(parse_after_colon $(xdpyinfo|grep dimensions))
show " PATH" $PATH
[ -n "$VIEWER" ] && echo "VIEWER=$VIEWER"

show " Date" "$(date)"
show " UTC Date" "$(date -u)"
show " this program" "$0"
show " uptime" "$(uptime)"
show " lsb_release -sa" "$(lsb_release -sa 2>/dev/null)"
show " linuxcnc" "$(command -v linuxcnc)"
show " pwd" "$(pwd -P)"
show " USER" "$USER"
show " LOGNAME" "$LOGNAME"
show " HOME" "$HOME"
show " EDITOR" "$EDITOR"
show " VISUAL" "$VISUAL"
show " LANGUAGE" "$LANGUAGE"
show " TERM" "$TERM"
show " COLORTERM" "$COLORTERM"
show " DISPLAY" "$DISPLAY"
show " DESKTOP" "$DESKTOP_SESSION"
show " display size" "$(parse_after_colon "$(xdpyinfo|grep dimensions)")"
show " PATH" "$PATH"
echo
echo "uname items:"
show " nodename -n" $(uname -n)
show " kernel-name -s" $(uname -s)
show " kernel-vers -v" $(uname -v)
show " machine -m" $(uname -m)
show " processor -p" $(uname -p)
show " platform -i" $(uname -i)
show " oper system -o" $(uname -o)
show " nodename -n" "$(uname -n)"
show " kernel-name -s" "$(uname -s)"
show " kernel-vers -v" "$(uname -v)"
show " machine -m" "$(uname -m)"
show " processor -p" "$(uname -p)"
show " platform -i" "$(uname -i)"
show " oper system -o" "$(uname -o)"
show ""
echo "/proc items:"
show " cmdline" $(< /proc/cmdline)
show " model name" $(parse_cpuinfo "model name")
show " cores" $(parse_cpuinfo "cpu cores")
show " cpu MHz" $(parse_cpuinfo "cpu MHz")
show " parport" $(cat /proc/ioports|grep parport)
show " serial" $(cat /proc/ioports|grep serial)
show " cmdline" "$(< /proc/cmdline)"
show " model name" "$(parse_cpuinfo "model name")"
show " cores" "$(parse_cpuinfo "cpu cores")"
show " cpu MHz" "$(parse_cpuinfo "cpu MHz")"
show " parport" "$(grep parport < /proc/ioports)"
show " serial" "$(grep serial < /proc/ioports)"
echo
echo "Versions:"
show " gcc" $(gcc --version|head -1)
show " python" $(@PYTHON@ --version 2>&1)
show " git" $(tryversion git)
show " git commit" $(git_commit)
show " tcl" $(echo "puts $::tcl_version"|tclsh)
show " tk" $(echo "puts $::tk_version;destroy ."|wish)
show " glade" $(tryversion glade)
show " gcc" "$(gcc --version|head -1)"
show " python" "$(@PYTHON@ --version 2>&1)"
show " git" "$(tryversion git)"
show " git commit" "$(git_commit)"
show " tcl" "$(echo "puts $::tcl_version"|tclsh)"
show " tk" "$(echo "puts $::tk_version;destroy ."|wish)"
show " glade" "$(tryversion glade)"
echo
echo "linuxcnc_var all:"
echo
for n in $(linuxcnc_var all) ; do
show "${n%%=*}" ${n##*=}
show "${n%%=*}" "${n##*=}"
done

echo
Expand Down
Loading

0 comments on commit 6ce09eb

Please sign in to comment.