"tmux has-session" search is prefix-matching

I'm trying to determine if a tmux session exists by has-session command.

If I have a session named abcdf:

adm@VirtualBox:/$ tmux -V
tmux 2.1
adm@VirtualBox:/$ tmux ls
abcdf: 1 windows (created Fri Feb  3 16:19:20 2017) [237x56] (attached)

has-session command will return the session named a,ab,abc,abcd,abcdf is exist (error code=0)

adm@VirtualBox:/$ tmux has -t a
adm@VirtualBox:/$ echo $?
0
adm@VirtualBox:/$ tmux has -t ab
adm@VirtualBox:/$ echo $?
0
adm@VirtualBox:/$ tmux has -t abc
adm@VirtualBox:/$ echo $?
0
adm@VirtualBox:/$ tmux has -t abcd
adm@VirtualBox:/$ echo $?
0
adm@VirtualBox:/$ tmux has -t abcdf
adm@VirtualBox:/$ echo $?
0
adm@VirtualBox:/$ 

and the following is not exist (error code=1)

adm@VirtualBox:/$ tmux has -t b
can't find session b
adm@VirtualBox:/$ echo $?
1
adm@VirtualBox:/$ tmux has -t bc
can't find session bc
adm@VirtualBox:/$ echo $?
1
adm@VirtualBox:/$ tmux has -t bcd
can't find session bcd
adm@VirtualBox:/$ echo $?
1

It seems like this command will match the sessions by prefix-matching, is this correct? How do I search the session exact the name I want?


Solution 1:

The solution is to use = e.g.

-t=sessionname

This does an exact match.

(Having the same issue today and found via: https://github.com/tmux/tmux/issues/346)