From bc3a273f84803fafd8e8317a36cfc94dcf2386ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Tue, 21 Apr 2026 18:57:51 +0200 Subject: [PATCH] tools: Fix shellcheck issues in containerd-shim-katadbg-v2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address shellcheck warnings including proper variable quoting, use of [[ ]] over [ ], declaring and assigning variables separately, and adding appropriate shellcheck disable directives where needed. Signed-off-by: Fabiano FidĂȘncio Made-with: Cursor --- tools/containerd-shim-katadbg-v2 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/containerd-shim-katadbg-v2 b/tools/containerd-shim-katadbg-v2 index 01c56c88b5..66b4795789 100755 --- a/tools/containerd-shim-katadbg-v2 +++ b/tools/containerd-shim-katadbg-v2 @@ -25,7 +25,7 @@ SHIM_BINARY=/go/src/github.com/kata-containers/kata-containers/src/runtime/__deb DLV_PORT=12345 # Edit the following to make sure dlv is in the PATH -export PATH=/usr/local/go/bin/:$PATH +export PATH=/usr/local/go/bin/:${PATH} # The shim can be called multiple times for the same container. # If it is already running, subsequent calls just return the socket address that @@ -36,7 +36,7 @@ export PATH=/usr/local/go/bin/:$PATH # debugging the actual server process. # To avoid running additional debuggers and blocking on them, we use a lock file. LOCK_FILE=/tmp/shim_debug.lock -if [ -e $LOCK_FILE ]; then +if [[ -e "${LOCK_FILE}" ]]; then NO_DEBUG=1 fi @@ -50,8 +50,8 @@ case "$1" in esac -if [ "$NO_DEBUG" == "1" ]; then - $SHIM_BINARY "$@" +if [[ "${NO_DEBUG}" == "1" ]]; then + ${SHIM_BINARY} "$@" exit $? fi @@ -74,12 +74,12 @@ fi SHIMOUTPUT=$(mktemp /tmp/shim_output_XXXXXX) -cat > $LOCK_FILE << EOF +cat > "${LOCK_FILE}" << EOF #!/bin/bash -dlv exec ${SHIM_BINARY} --headless --listen=:$DLV_PORT --accept-multiclient -r stdout:$SHIMOUTPUT -r stderr:$SHIMOUTPUT -- "\$@" -rm $LOCK_FILE +dlv exec ${SHIM_BINARY} --headless --listen=:${DLV_PORT} --accept-multiclient -r stdout:${SHIMOUTPUT} -r stderr:${SHIMOUTPUT} -- "\$@" +rm ${LOCK_FILE} EOF -chmod +x $LOCK_FILE +chmod +x "${LOCK_FILE}" # We're starting dlv as a background task, so that it continues to run while # this script returns, letting the caller resume its execution. @@ -92,10 +92,10 @@ ${LOCK_FILE} "$@" > /tmp/dlv_output 2>&1 & # wait for the output file of the shim process to be filled with the address. -while [ ! -s $SHIMOUTPUT ]; do +while [[ ! -s "${SHIMOUTPUT}" ]]; do sleep 1 done # write the adress to stdout -cat $SHIMOUTPUT +cat "${SHIMOUTPUT}" exit 0