[AZ-615] run-tests-jetson: resolve ~ before quoted heredoc cd

REMOTE_DIR defaults to ~/gps-denied-onboard. rsync expands the
leading tilde server-side, but the later 'bash -s <<EOF' heredoc
embeds the value literally inside cd "$REMOTE_DIR" -- and bash does
NOT expand ~ inside double quotes, so the heredoc step bails out
with 'No such file or directory'. Resolve any leading ~ against the
remote $HOME up-front so the value is safe to double-quote in both
contexts.

The previous successful Jetson runs (tasks 2388 / 915484) were
one-off ssh commands that never hit this code path; this commit
makes the script actually work end-to-end.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-05-18 09:04:43 +03:00
parent 324bbd6367
commit b7012d2787
+18
View File
@@ -26,6 +26,11 @@ set -euo pipefail
# Configuration
SSH_ALIAS="${JETSON_SSH_ALIAS:-jetson-e2e}"
# REMOTE_DIR may contain a leading '~' for convenience. rsync expands it
# server-side, but the later `bash -s <<EOF` heredoc embeds it as a
# literal string that ends up inside `cd "..."` — and bash does NOT
# expand '~' inside double quotes. To keep one variable that works in
# both contexts we resolve '~' to the remote $HOME up-front.
REMOTE_DIR="${JETSON_REMOTE_DIR:-~/gps-denied-onboard}"
COMPOSE_FILE="docker-compose.test.jetson.yml"
@@ -50,6 +55,19 @@ EOF
exit 65
fi
# Resolve any leading '~' in REMOTE_DIR against the remote $HOME so the
# value can be safely double-quoted in later heredocs.
case "${REMOTE_DIR}" in
"~"|"~/"*)
REMOTE_HOME="$(ssh "${SSH_ALIAS}" 'printf %s "$HOME"')"
if [ -z "${REMOTE_HOME}" ]; then
echo "ERROR: failed to resolve \$HOME on ${SSH_ALIAS}" >&2
exit 66
fi
REMOTE_DIR="${REMOTE_HOME}${REMOTE_DIR#\~}"
;;
esac
echo "[run-tests-jetson] using ssh alias: ${SSH_ALIAS}"
echo "[run-tests-jetson] remote dir: ${REMOTE_DIR}"
echo "[run-tests-jetson] compose file: ${COMPOSE_FILE}"