From 7d95850461f7912b84bd08514eecfcd8e20c0cdb Mon Sep 17 00:00:00 2001 From: veg Date: Sat, 4 Jul 2026 09:25:27 +0000 Subject: [PATCH] fix: .party-notify uses PARTY_TMUX, not bare tmux from PATH --- party | 15 ++++++++++++--- tests/90-notifications.bats | 11 +++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/party b/party index cb6e1ce..b580934 100755 --- a/party +++ b/party @@ -441,14 +441,23 @@ tmux_party_setup_server() { # keeps it out of typical `ls` listings. The per-party private dir # hosts at most one socket so a fixed name is safe. notify_script="${sock%/*}/.party-notify" - cat > "$notify_script" <<'EOF' + # Two heredocs: the first (expanding) pins the tmux binary the party + # was hosted with — a bare `tmux` from the server's PATH may be a + # different, older binary than $PARTY_TMUX, which is the whole reason + # PARTY_TMUX exists. The second (quoted) is the static body. A + # PARTY_TMUX containing a double quote or $ would break the pin; + # that's accepted — it's the host's own env var on their own party. + cat > "$notify_script" <> "$notify_script" <<'EOF' # Auto-generated by party. Fan a display-message out to every client # of the party server. Args: $1 = socket, $2 = client_user, $3 = "joined"|"left" sock="$1"; user="$2"; verb="$3" -tmux -S "$sock" list-clients -F '#{client_name}' 2>/dev/null \ +"$tmux" -S "$sock" list-clients -F '#{client_name}' 2>/dev/null \ | while read -r c; do - tmux -S "$sock" display-message -c "$c" "$user $verb the party" 2>/dev/null || : + "$tmux" -S "$sock" display-message -c "$c" "$user $verb the party" 2>/dev/null || : done EOF chmod 0755 "$notify_script" diff --git a/tests/90-notifications.bats b/tests/90-notifications.bats index 1f6879b..6eb06a5 100644 --- a/tests/90-notifications.bats +++ b/tests/90-notifications.bats @@ -51,3 +51,14 @@ party_rec() { printf '%s/party-%s:%s.d/roster\n' "$PARTY_SOCKET_DIR" "$USER" "$1 [ "$g" = "$TMUX_PARTY_GROUP" ] \ || { echo "notify_script group=$g, expected $TMUX_PARTY_GROUP"; false; } } + +@test ".party-notify pins the PARTY_TMUX binary used at host time" { + "$PARTY_BIN" host pintmux + rec=$(party_rec pintmux) + sock=$(awk -F= '$1=="SOCKET"{print $2}' "$rec") + notify_script="${sock%/*}/.party-notify" + # The helper must not reach for a bare `tmux` from PATH: it pins the + # binary the party was hosted with (PARTY_TMUX, default "tmux"). + grep -q "^tmux=\"${PARTY_TMUX:-tmux}\"$" "$notify_script" + ! grep -qE '^[[:space:]]*tmux -S' "$notify_script" +}