fix: pin absolute script path in status-right widget
The #() body runs with the tmux server's PATH; a bare 'party' silently broke the widget for uninstalled or non-standard-prefix hosts.
This commit is contained in:
parent
7d95850461
commit
2ef4eb49ce
2 changed files with 23 additions and 2 deletions
19
party
19
party
|
|
@ -430,6 +430,22 @@ compute_default_party_name() {
|
|||
printf 'party-%s\n' "$rand"
|
||||
}
|
||||
|
||||
# Absolute path to this script, for embedding in tmux server state that
|
||||
# outlives this invocation (the status-right #() widget runs with the
|
||||
# tmux server's PATH, which need not contain an installed `party`).
|
||||
# $0 forms: absolute — take it; relative-with-slash — anchor to cwd;
|
||||
# bare word — resolve via PATH, falling back to $0 verbatim. No `--`
|
||||
# after command -v/dirname/basename: old illumos userland predates it,
|
||||
# and $0 here never starts with '-'.
|
||||
party_self_path() {
|
||||
case "$0" in
|
||||
/*) printf '%s\n' "$0" ;;
|
||||
*/*) printf '%s/%s\n' "$(cd "$(dirname "$0")" && pwd)" \
|
||||
"$(basename "$0")" ;;
|
||||
*) command -v "$0" 2>/dev/null || printf '%s\n' "$0" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
# After spawning the party server, configure status line and hooks.
|
||||
# All commands run against -S "$sock". Every literal name embedded
|
||||
|
|
@ -469,8 +485,9 @@ EOF
|
|||
chgrp "$TMUX_PARTY_GROUP" "$notify_script"
|
||||
|
||||
"$PARTY_TMUX" -S "$sock" set-option -s exit-empty on
|
||||
party_self=$(party_self_path)
|
||||
"$PARTY_TMUX" -S "$sock" set-option -g status-right \
|
||||
"party: #(party who --short --socket $sock 2>/dev/null)"
|
||||
"party: #($party_self who --short --socket $sock 2>/dev/null)"
|
||||
# Join/leave broadcast. Hook bodies fan a display-message out to
|
||||
# every attached client of THIS server via the notify helper script.
|
||||
# tmux substitutes #{client_user} before running the shell command.
|
||||
|
|
|
|||
|
|
@ -19,12 +19,16 @@ party_rec() { printf '%s/party-%s:%s.d/roster\n' "$PARTY_SOCKET_DIR" "$USER" "$1
|
|||
[[ "$out" == *"client-detached"* ]]
|
||||
}
|
||||
|
||||
@test "status-right widget is configured" {
|
||||
@test "status-right widget is configured with an absolute self path" {
|
||||
"$PARTY_BIN" host srtest
|
||||
rec=$(party_rec srtest)
|
||||
sock=$(awk -F= '$1=="SOCKET"{print $2}' "$rec")
|
||||
sr=$(tmux -S "$sock" show-options -gv status-right)
|
||||
[[ "$sr" == *"party who --short"* ]]
|
||||
# The #() body is executed with the tmux server's PATH, which need
|
||||
# not contain an installed `party` — the widget must pin the absolute
|
||||
# path of the script that hosted the party.
|
||||
[[ "$sr" == "party: #(/"* ]]
|
||||
}
|
||||
|
||||
@test "client-attached hook invokes a notify helper that broadcasts display-message" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue