Skip to content

Commit 1d4d60d

Browse files
Mic92Qubasa
andcommitted
Add SSH command debug logging
Adds colored debug output showing the full SSH command being executed when debug mode is enabled. Co-authored-by: Qubasa <consulting@qube.email>
1 parent 45b4628 commit 1d4d60d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/nixos-anywhere.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,15 @@ runSshTimeout() {
470470
timeout 10 ssh "${sshArgs[@]}" "$sshConnection" "$@"
471471
}
472472
runSsh() {
473-
# shellcheck disable=SC2029
474-
# We want to expand "$@" to get the command to run over SSH
475-
ssh "$sshTtyParam" "${sshArgs[@]}" "$sshConnection" "$@"
473+
(
474+
set +x
475+
if [[ -n ${enableDebug} ]]; then
476+
echo -e "\033[1;34mSSH COMMAND:\033[0m ssh $sshTtyParam ${sshArgs[*]} $sshConnection $*\n"
477+
fi
478+
# shellcheck disable=SC2029
479+
# We want to expand "$@" to get the command to run over SSH
480+
ssh "$sshTtyParam" "${sshArgs[@]}" "$sshConnection" "$@"
481+
)
476482
}
477483

478484
nixCopy() {

0 commit comments

Comments
 (0)