Hello,
I am having problems with a tmux command, has-session <target-session> and finding what looks like a bug, or mismatch with the documentation. I am trying to determine if a named session and window already exists, and if not, start it with a command.
I am finding that has-session is returning a success when another session window matches the prefix that I am looking for. This should be avoidable with the = qualifier, to require an exact match.
In the man page:
target-session is tried as, in order:
1. A session ID prefixed with a $.
2. An exact name of a session (as listed by the list-sessions command).
3. The start of a session name, for example ‘mysess’ would match a session named ‘mysession’.
4. A glob(7) pattern which is matched against the session name.
If the session name is prefixed with an ‘=’, only an exact match
is accepted (so ‘=mysess’ will only match exactly ‘mysess’, not
‘mysession’).
The following command history demonstrates the behavior that looks incorrect to me. Am I doing something wrong?
/workspace > tmux list-sessions
sheldon: 2 windows (created Thu Aug 7 18:29:49 2025) (attached)
/workspace > tmux list-windows -t sheldon
0: zsh* (1 panes) [198x60] [layout b4bd,198x60,0,0,0] @0 (active)
3: payment-events- (1 panes) [198x60] [layout b4c0,198x60,0,0,3] @3
/workspace > tmux has-session -t sheldon:payment; echo $?
0
/workspace > tmux has-session -t=sheldon:payment; echo $?
0
/workspace > tmux has-session -t=sheldon:fff; echo $?
can't find window: fff
1
I expected the command tmux has-session -t=sheldon:payment to fail with a non-zero exit code, since as you can see, no exact match session names exist. The command generally works, when specifying a session and window name that clearly does not match.
I installed tmux from the system package manager. Here's a little about my environment:
/workspace > uname -a
Linux sheldon-vm 6.10.14-linuxkit #1 SMP Sat May 17 08:28:57 UTC 2025 aarch64 GNU/Linux
/workspace > lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
/workspace > tmux -V
tmux 3.3a
/workspace > cat ~/.tmux.conf
set -g mouse on
set -g history-limit 50000
/workspace > env | grep -i tmux
TERM=tmux-256color
TERM_PROGRAM=tmux
TMUX=/tmp/tmux-0/default,50663,0
TMUX_PANE=%0
Thanks,
Nick