fix: .party-notify uses PARTY_TMUX, not bare tmux from PATH
This commit is contained in:
parent
fc366f48fa
commit
7d95850461
2 changed files with 23 additions and 3 deletions
15
party
15
party
|
|
@ -441,14 +441,23 @@ tmux_party_setup_server() {
|
||||||
# keeps it out of typical `ls` listings. The per-party private dir
|
# keeps it out of typical `ls` listings. The per-party private dir
|
||||||
# hosts at most one socket so a fixed name is safe.
|
# hosts at most one socket so a fixed name is safe.
|
||||||
notify_script="${sock%/*}/.party-notify"
|
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" <<EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
tmux="$PARTY_TMUX"
|
||||||
|
EOF
|
||||||
|
cat >> "$notify_script" <<'EOF'
|
||||||
# Auto-generated by party. Fan a display-message out to every client
|
# 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"
|
# of the party server. Args: $1 = socket, $2 = client_user, $3 = "joined"|"left"
|
||||||
sock="$1"; user="$2"; verb="$3"
|
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
|
| 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
|
done
|
||||||
EOF
|
EOF
|
||||||
chmod 0755 "$notify_script"
|
chmod 0755 "$notify_script"
|
||||||
|
|
|
||||||
|
|
@ -51,3 +51,14 @@ party_rec() { printf '%s/party-%s:%s.d/roster\n' "$PARTY_SOCKET_DIR" "$USER" "$1
|
||||||
[ "$g" = "$TMUX_PARTY_GROUP" ] \
|
[ "$g" = "$TMUX_PARTY_GROUP" ] \
|
||||||
|| { echo "notify_script group=$g, expected $TMUX_PARTY_GROUP"; false; }
|
|| { 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"
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue