Skip to content

Commit

Permalink
Merge pull request #3304 from BsAtHome/fix_shellcheck-cd-exit
Browse files Browse the repository at this point in the history
Fix more shellcheck problems
  • Loading branch information
andypugh authored Feb 6, 2025
2 parents d7588c4 + 2d257a1 commit ad5ba69
Show file tree
Hide file tree
Showing 29 changed files with 101 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo -u ./cairodraw.py ./cairodraw.ui
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/by-widget/combobox.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo -u combobox.py combobox.ui
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/by-widget/combobox_manual_list.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo -u ./combobox_manual_list.py ./combobox_manual_list.ui
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/by-widget/radiobutton.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo -u ./radio.py ./radio.ui
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/by-widget/sourceview.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo -u ./sourceview.py ./sourceview.ui
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/by-widget/spinbutton.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo -u spinbutton.py spinbutton.ui
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/class-callback/class_callback.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo -u ./class_callback.py -H ./class_callback.hal ./class_callback.ui
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/colored-label/coloredlabel.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo -u ./coloredlabel.py -H ./coloredlabel.hal ./coloredlabel.ui
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/complex/complex.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo -u ./complex.py -H ./complex.hal ./complex.ui
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/glade-manual.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo ./glade-manual.ui
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/gladevcp-test.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo ./gladevcp-test.ui
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/helloWorld/helloworld.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo -H ./hw.hal ./hw.ui
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/mdi-command-example/owordsub.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo ./owordsub.ui
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/mdi-command-example/speed.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo ./speed.ui
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/mdi-command-example/whoareyou.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo ./whoareyou.ui
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/simple-callback/simple-callback.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo -u ./simplecallback.py ./simplecallback.ui
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/templates/classhandler.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo -u ./classhandler.py ./button.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo -u ./classhandler_persistent.py -U debug=2 -U "print 'debug=%d' % debug" ./button.ui
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/templates/functionhandler.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

gladevcp_demo -u ./functionhandler.py ./button.ui
23 changes: 12 additions & 11 deletions configs/apps/halrun/halrun.demo
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/bash

prog=$(basename $0)
prog=$(basename "$0")
thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
HALFILE="$thisdir"/help.hal

cd ;# so user can use halcmd 'save' to create a file
# Don't care if cd succeeds. Just so user can use halcmd 'save' to create a file in $HOME
cd || true

function popup () {
msg="$*"
Expand All @@ -21,9 +22,9 @@ EOF
} ;# popup


[ X"$TERM" = Xdumb ] && TERM=xterm
[ -x "$(which $COLORTERM)" ] && TERM=$COLORTERM
[ -z $TERM ] && TERM=xterm
[ "$TERM" = "dumb" ] && TERM=xterm
[ -x "$(which "$COLORTERM")" ] && TERM=$COLORTERM
[ -z "$TERM" ] && TERM=xterm

# wip: xterm is well-behaved, some other terminals are not
# for now: force to xterm
Expand All @@ -33,11 +34,11 @@ REALTIME=$(linuxcnc_var REALTIME)
# make sure TERM uses the expected halrun (rip or install)
HALRUN=$(which halrun)

if [ ! -z "$debug" ] ; then
echo COLORTERM=$COLORTERM
echo TERM=$TERM
echo HALRUN=$HALRUN
echo REALTIME=$REALTIME
if [ -n "$debug" ] ; then
echo "COLORTERM=$COLORTERM"
echo "TERM=$TERM"
echo "HALRUN=$HALRUN"
echo "REALTIME=$REALTIME"
fi

if $REALTIME status >/dev/null ; then
Expand All @@ -51,7 +52,7 @@ fi
# terminate any other halrun instance:
$HALRUN -U >/dev/null 2>&1

if [ X"$TERM" = Xxterm ] ; then
if [ "$TERM" = "xterm" ] ; then
$TERM -geometry 80x40 \
-sb \
-fg black -bg ivory2 \
Expand Down
2 changes: 1 addition & 1 deletion configs/apps/xhc-hb04/xhc-hb04-layout1.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

./xhc-hb04.sh layout1
2 changes: 1 addition & 1 deletion configs/apps/xhc-hb04/xhc-hb04-layout2.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

./xhc-hb04.sh layout2
2 changes: 1 addition & 1 deletion configs/apps/xhc-hb04/xhc-hb04.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

# use default layout
./xhc-hb04.sh
10 changes: 5 additions & 5 deletions configs/apps/xhc-hb04/xhc-hb04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"
cd "$thisdir" || { echo "E: Could not change directory to '$thisdir'"; exit 1; }

LAYOUT=${1:-""}

[ -x "$(which $COLORTERM)" ] && TERM=$COLORTERM
[ -z $TERM ] && TERM=xterm
[ -x "$(which "$COLORTERM")" ] && TERM="$COLORTERM"
[ -z "$TERM" ] && TERM=xterm
# when invoked from Application menu and RIP, may have TERM=dumb
[ x"$TERM" = xdumb ] && TERM=xterm
[ "$TERM" = "dumb" ] && TERM=xterm

XHC_HB04=$(which xhc-hb04)
HALLIB_DIR=$(linuxcnc_var HALLIB_DIR)
Expand All @@ -20,7 +20,7 @@ case $LAYOUT in
esac
dashI="-I $CFG"

if [ ! -z "$debug" ] ; then
if [ -n "$debug" ] ; then
echo "COLORTERM=$COLORTERM"
echo "TERM=$TERM"
echo "XHC_HB04=$XHC_HB04"
Expand Down
2 changes: 1 addition & 1 deletion configs/sim/axis/gladevcp/set-param-from-ini.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

cd $(dirname $::argv0)
cd "$(dirname "$0")" || { echo "E: Could not change directory to '$(dirname "$0")'"; exit 1; }

gladevcp -u ./meter_scale.py ./meter_scale.ui &

Expand Down
32 changes: 19 additions & 13 deletions scripts/hal_demo
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
# Copyright (c) 2004-2009 All rights reserved.
#*******************************************************************/
if [ ! $1 ] ; then
if [ -z "$1" ] ; then
echo "Usage: scripts/hal_demo <demo_name>"
echo "Run from the emc2 directory only"
# print the list of demos
Expand All @@ -28,7 +28,7 @@ fi
#
# the first demo isn't a real demo - it simply lists all the demos
#
if [ $1 = list ] ; then
if [ "$1" = "list" ] ; then
echo "Available demos are:"
echo " list - prints this list"
echo " load - loads hal core modules"
Expand All @@ -44,10 +44,10 @@ fi
#
# here is the "load" command
#
if [ $1 = load ] ; then
if [ "$1" = "load" ] ; then
# load the rtos and rtapi
if ! scripts/realtime start ; then
exit -1
exit 1
fi
# done
echo "RTAPI core loaded"
Expand All @@ -56,12 +56,12 @@ fi
#
# here is the "unload" command
#
if [ $1 = unload ] ; then
if [ "$1" = "unload" ] ; then
# unload any left-over modules
bin/halcmd unloadrt all
# unload the rtos and rtapi
if ! scripts/realtime stop ; then
exit -1
exit 1
fi
# done
echo "RTAPI core unloaded"
Expand All @@ -71,17 +71,19 @@ fi
# We're almost ready for the real demos, first we must
# make sure the rtapi core is loaded
#
HAL_LIB_STR=`/sbin/lsmod | awk '{print $1}' | grep -x hal_lib `
if [ ! "$HAL_LIB_STR" ] ; then
HAL_LIB_STR=$(/sbin/lsmod | awk '{print $1}' | grep -x hal_lib)
if [ -z "$HAL_LIB_STR" ] ; then
echo "All of the demos require the RTAPI and HAL_LIB modules"
echo "to be loaded. Use 'hal_demo load' to load them."
exit -1
exit 1
fi
#
# The first demo: "parport1" simply tests the parallel port
# this one is a step by step, tutorial/intro to HAL concepts
#
if [ $1 = parport1 ] ; then
# Don't care about read mangling backslashes, nothing read is used
# shellcheck disable=SC2162
if [ "$1" = "parport1" ] ; then
echo "(Comments that are part of the demo are in parenthesis.)"
echo "(This demo echos its commands to the screen so you can"
echo " see what each step does. Echoed commands start with '$')"
Expand Down Expand Up @@ -206,7 +208,9 @@ fi
# and halmeter.
# this one is also a step by step tutorial
#
if [ $1 = siggen ] ; then
# Don't care about read mangling backslashes, nothing read is used
# shellcheck disable=SC2162
if [ "$1" = "siggen" ] ; then
echo "(Comments that are part of the demo are in parenthesis.)"
echo "(This demo echos its commands to the screen so you can"
echo " see what each step does. Echoed commands start with '$')"
Expand Down Expand Up @@ -288,7 +292,9 @@ fi
# using siggen as a signal source.
# this one is also a step by step tutorial
#
if [ $1 = scope ] ; then
# Don't care about read mangling backslashes, nothing read is used
# shellcheck disable=SC2162
if [ "$1" = "scope" ] ; then
echo "The first part of this demo is identical to the siggen"
echo "demo. Hit enter to get started"
read
Expand Down Expand Up @@ -400,5 +406,5 @@ fi
#
echo "Sorry, there is no demo called '$1'"
scripts/hal_demo
exit -1
exit 1

20 changes: 12 additions & 8 deletions scripts/make-docs-pdf-index
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,23 @@ set -e
# --show-toplevel` because when building from dsc we don't have a
# git repo.
TOPLEVEL=${PWD}/..
cd ${TOPLEVEL}/docs
cd "${TOPLEVEL}"/docs

TITLE="LinuxCNC PDF docs ($(cat ${TOPLEVEL}/VERSION))"
TITLE="LinuxCNC PDF docs ($(cat "${TOPLEVEL}"/VERSION))"

rm -f index.html

echo "<html>" >> index.html
echo "<head><title>${TITLE}</title></head>" >> index.html
echo "<body><h1>${TITLE}</h1><p>" >> index.html
{
echo "<html>"
echo "<head><title>${TITLE}</title></head>"
echo "<body><h1>${TITLE}</h1><p>"
} >> index.html

for F in $(ls -1 *.pdf | sort); do
for F in $(ls -1 ./*.pdf | sort); do
echo " <a href=\"${F}\">$F</a><br>" >> index.html
done

echo "</body>" >> index.html
echo "</html>" >> index.html
{
echo "</body>"
echo "</html>"
} >> index.html
Loading

0 comments on commit ad5ba69

Please sign in to comment.