Skip to content

Commit 532a78d

Browse files
authored
Merge pull request #4242 from BsAtHome/fix_shellcheck_lastones
shellcheck: Fix remaining warnings in scripts.
2 parents fc8828c + 63d8855 commit 532a78d

4 files changed

Lines changed: 24 additions & 8 deletions

File tree

debian/update-dch-from-git

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ source scripts/githelper.sh
99
githelper "$1"
1010

1111
GIT_VERSION=$(scripts/get-version-from-git "$GIT_BRANCH")
12+
# Need to use $? because we need the output capture
13+
# shellcheck disable=SC2181
1214
if [ $? -ne 0 ]; then
1315
echo "error determining version!"
1416
exit 1

docs/src/asciideps

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
set -e
44

55
test -z "$1" && exit 0
66
test -f "$1" || exit 1
77

8+
includestack=( )
9+
810
includes () {
911
DIR=$(dirname "$1")
1012

11-
for f in $(sed -ne "s|^include::\(.*\)\[\]$|$DIR/\1|p" "$1"); do
13+
while IFS= read -r f; do
1214
# components_gen.adoc will contain only generated content
1315
case "$f" in
1416
*/components_gen.adoc)
1517
touch "$f"
1618
;;
1719
esac
1820
echo "$f"
21+
ff=$(realpath "$f")
22+
if [[ " ${includestack[*]} " =~ [[:space:]]${ff}[[:space:]] ]]; then
23+
echo "Include file recursion detected on '$f'. Skipped." >&2
24+
continue
25+
fi
26+
includestack+=("$ff")
1927
includes "$f"
20-
done
28+
unset 'includestack[${#includestack[@]}-1]'
29+
done < <(sed -ne "s|^include::\(.*\)\[\]$|$DIR/\1|p" "$1")
2130
}
2231

2332
images() {

scripts/linuxcnc_info.in

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function parse_after_colon () {
9090

9191
function tryversion () {
9292
prog="$1"
93-
if [ $(command -v "$prog") ] ; then
93+
if [ "$(command -v "$prog")" ] ; then
9494
ans=$($prog --version 2>/dev/null)
9595
if [ -z "$ans" ] ; then
9696
echo "?"
@@ -165,9 +165,14 @@ for n in $(linuxcnc_var all) ; do
165165
show "${n%%=*}" "${n##*=}"
166166
done
167167

168+
# Not everybody runs Debian based distros
168169
echo
169-
echo "dpkg -l '*linuxcnc*':"
170-
dpkg -l '*linuxcnc*'
170+
if command -v dpkg > /dev/null; then
171+
echo "dpkg -l '*linuxcnc*':"
172+
dpkg -l '*linuxcnc*'
173+
else
174+
echo "No 'dpkg' available, different distro, probably."
175+
fi
171176
echo
172177

173178
[ -n "$VIEWER" ] && $VIEWER "$ofile"

scripts/rip-environment.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ if ! $as_command; then
118118
else
119119
_iningc () {
120120
case "$3" in
121-
*.ini) COMPREPLY=($(compgen -o plusdirs -f -X '!*.ngc' -- "$2")) ;;
122-
*) COMPREPLY=($(compgen -o plusdirs -f -X '!*.ini' -- "$2"))
121+
*.ini) mapfile -t COMPREPLY < <(compgen -o plusdirs -f -X '!*.ngc' -- "$2") ;;
122+
*) mapfile -t COMPREPLY < <(compgen -o plusdirs -f -X '!*.ini' -- "$2")
123123
esac
124124
}
125125
complete -o plusdirs -F _iningc emc axis

0 commit comments

Comments
 (0)