From 2afe7d830660b2cc3b67416e8a514878a4e8092c Mon Sep 17 00:00:00 2001 From: Sebastian Mengwall Date: Thu, 1 Jan 2026 18:45:30 +0000 Subject: [PATCH] fix(tmux): use heredoc for config to handle special characters The previous implementation using inline variable assignment and printf caused issues with custom tmux configs containing special characters: 1. `TMUX_CONFIG="${TMUX_CONFIG}"` - Terraform's templatefile substitutes the multi-line config inline, causing bash to interpret tmux commands (like `set -g`, `bind C-s`) as shell commands. 2. `printf "$TMUX_CONFIG"` - The `%` character in tmux's default horizontal split keybind (`bind %`) is interpreted as a printf format specifier, corrupting the output. Changes: - Use heredoc with `read -r -d ''` for safe variable assignment - Use `cat <<<` instead of `printf` for output - Add `|| true` to handle read's non-zero exit on EOF --- registry/anomaly/modules/tmux/scripts/run.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/registry/anomaly/modules/tmux/scripts/run.sh b/registry/anomaly/modules/tmux/scripts/run.sh index b3c518c5..440cc373 100755 --- a/registry/anomaly/modules/tmux/scripts/run.sh +++ b/registry/anomaly/modules/tmux/scripts/run.sh @@ -4,7 +4,9 @@ BOLD='\033[0;1m' # Convert templated variables to shell variables SAVE_INTERVAL="${SAVE_INTERVAL}" -TMUX_CONFIG="${TMUX_CONFIG}" +read -r -d '' TMUX_CONFIG << 'TMUX_EOF' || true +${TMUX_CONFIG} +TMUX_EOF # Function to install tmux install_tmux() { @@ -73,7 +75,7 @@ setup_tmux_config() { mkdir -p "$config_dir" if [ -n "$TMUX_CONFIG" ]; then - printf "$TMUX_CONFIG" > "$config_file" + cat <<< "$TMUX_CONFIG" > "$config_file" printf "$${BOLD}Custom tmux configuration applied at {$config_file} \n\n" else cat > "$config_file" << EOF