Skip to content

Conversation

@03kalven
Copy link
Contributor

@03kalven 03kalven commented Jan 1, 2026

Description

Fix custom tmux config handling. Two bugs:

  1. TMUX_CONFIG="${TMUX_CONFIG}" - Terraform substitutes config inline, bash interprets set -g etc as shell commands
  2. printf "$TMUX_CONFIG" - % in bind % treated as format specifier

Type of Change

  • New module
  • New template
  • Bug fix
  • Feature/enhancement
  • Documentation
  • Other

Module Information

Path: registry/anomaly/modules/tmux
New version: 1.0.4
Breaking change: [x] No

Testing & Validation

  • Tests pass (bun test)
  • Code formatted (bun fmt)
  • Changes tested locally

Related Issues

None

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
@03kalven 03kalven marked this pull request as draft January 1, 2026 18:47
@03kalven 03kalven marked this pull request as ready for review January 1, 2026 18:50
@matifali matifali requested review from 35C4n0r and Copilot January 2, 2026 06:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes custom tmux configuration handling in the tmux module by addressing two critical bugs: shell command interpretation of tmux config directives (like set -g) and format specifier issues with % characters in tmux bindings (like bind %). The fix implements heredoc for variable assignment and here-string for output.

  • Replaces direct variable assignment with heredoc to prevent bash from interpreting tmux configuration as shell commands
  • Changes printf to cat <<< to avoid treating % characters in tmux config as format specifiers

@03kalven 03kalven force-pushed the fix-tmux-config-special-chars branch from 075b283 to 48cd75d Compare January 2, 2026 20:23
Copy link
Collaborator

@35C4n0r 35C4n0r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @03kalven
LGTM !

@35C4n0r 35C4n0r changed the title fix(tmux): use heredoc for config to handle special characters fix(modules/anomaly/tmux): fix config handling in run scripts Jan 4, 2026
@35C4n0r 35C4n0r enabled auto-merge (squash) January 4, 2026 03:10
@35C4n0r 35C4n0r merged commit accf5a3 into coder:main Jan 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants