Discussion:
if-shell not working in tmux 1.9/1.9a on Debian Jessie
Robert LeBlanc
2015-03-26 05:53:57 UTC
Permalink
I'm trying to make my .tmux.conf work for both 1.8 and 1.9 while
depreciating the old syntax. I can't get 1.9 (from Debian) or 1.9a
(compiled from source) to work properly. I open a new tmux session and run:

if-shell "[[ `/usr/bin/tmux -V` = *1.9* ]]" "display-message 'Yes'"
"display-message 'No'"

I always get "No". If I open up tmux on CentOS7 with 1.8 and adjust the
line to test for 1.8, I get "Yes" as expected. I get "No" if I change it to
1.9. So it is working just fine in 1.8.

Any idea why it's not working on 1.9 for me?

Thank you,
Robert LeBlanc
Benoit Pierre
2015-03-26 06:13:39 UTC
Permalink
Post by Robert LeBlanc
I'm trying to make my .tmux.conf work for both 1.8 and 1.9 while
depreciating the old syntax. I can't get 1.9 (from Debian) or 1.9a (compiled
if-shell "[[ `/usr/bin/tmux -V` = *1.9* ]]" "display-message 'Yes'"
"display-message 'No'"
I always get "No". If I open up tmux on CentOS7 with 1.8 and adjust the line
to test for 1.8, I get "Yes" as expected. I get "No" if I change it to 1.9.
So it is working just fine in 1.8.
Are you sure it's not due to different shells and the use of "[[ ]]"
instead of "[ ]" ?
Post by Robert LeBlanc
dash -c '[[ "`tmux -V`" = *2.0* ]]'; echo $?
dash: 1: [[: not found
127
Post by Robert LeBlanc
bash -c '[[ "`tmux -V`" = *2.0* ]]'; echo $?
0

Also, note the additional double quotes for the call to `tmux -V`.

Cheers,
--
A: Because it destroys the flow of conversation.
Q: Why is top posting dumb?
Robert LeBlanc
2015-03-26 06:31:58 UTC
Permalink
Post by Robert LeBlanc
Post by Robert LeBlanc
I'm trying to make my .tmux.conf work for both 1.8 and 1.9 while
depreciating the old syntax. I can't get 1.9 (from Debian) or 1.9a
(compiled
Post by Robert LeBlanc
if-shell "[[ `/usr/bin/tmux -V` = *1.9* ]]" "display-message 'Yes'"
"display-message 'No'"
I always get "No". If I open up tmux on CentOS7 with 1.8 and adjust the
line
Post by Robert LeBlanc
to test for 1.8, I get "Yes" as expected. I get "No" if I change it to
1.9.
Post by Robert LeBlanc
So it is working just fine in 1.8.
Are you sure it's not due to different shells and the use of "[[ ]]"
instead of "[ ]" ?
Post by Robert LeBlanc
dash -c '[[ "`tmux -V`" = *2.0* ]]'; echo $?
dash: 1: [[: not found
127
Post by Robert LeBlanc
bash -c '[[ "`tmux -V`" = *2.0* ]]'; echo $?
0
Also, note the additional double quotes for the call to `tmux -V`.
Cheers,
My shell is bash, but I'm not sure if tmux executes in my shell or it's
own. I can't get dash to pass, and I don't see a need for the extra double
quotes in bash.

***@rdleblanc-laptop:/tmp$ tmux -V
tmux 1.9
***@rdleblanc-laptop:/tmp$ dash -c '[ "`tmux -V`" = *1.9* ]'; echo $?
1
***@rdleblanc-laptop:/tmp$ bash -c '[[ "`tmux -V`" = *1.9* ]]'; echo
$?

0
***@rdleblanc-laptop:/tmp$ bash -c '[[ `tmux -V` = *1.9* ]]'; echo $?


0

I'm really at a loss. The CentOS box doesn't have dash, so if tmux is
specifically using that, then I can see it as being the problem, but I
would expect that it would us my shell.

Thanks,
Robert LeBlanc
Robert LeBlanc
2015-03-26 06:41:06 UTC
Permalink
Post by Robert LeBlanc
Post by Robert LeBlanc
Post by Robert LeBlanc
I'm trying to make my .tmux.conf work for both 1.8 and 1.9 while
depreciating the old syntax. I can't get 1.9 (from Debian) or 1.9a
(compiled
Post by Robert LeBlanc
if-shell "[[ `/usr/bin/tmux -V` = *1.9* ]]" "display-message 'Yes'"
"display-message 'No'"
I always get "No". If I open up tmux on CentOS7 with 1.8 and adjust the
line
Post by Robert LeBlanc
to test for 1.8, I get "Yes" as expected. I get "No" if I change it to
1.9.
Post by Robert LeBlanc
So it is working just fine in 1.8.
Are you sure it's not due to different shells and the use of "[[ ]]"
instead of "[ ]" ?
Post by Robert LeBlanc
dash -c '[[ "`tmux -V`" = *2.0* ]]'; echo $?
dash: 1: [[: not found
127
Post by Robert LeBlanc
bash -c '[[ "`tmux -V`" = *2.0* ]]'; echo $?
0
Also, note the additional double quotes for the call to `tmux -V`.
Cheers,
My shell is bash, but I'm not sure if tmux executes in my shell or it's
own. I can't get dash to pass, and I don't see a need for the extra double
quotes in bash.
tmux 1.9
1
echo $?
0
0
I'm really at a loss. The CentOS box doesn't have dash, so if tmux is
specifically using that, then I can see it as being the problem, but I
would expect that it would us my shell.
Thanks,
Robert LeBlanc
OK, looks like tmux is using dash:

***@rdleblanc-laptop:/tmp$ dash -c '[ "`tmux -V`" = "tmux 1.9" ]';
echo $?

0

if-shell '[ "`tmux -V`" = "tmux 1.9" ]' 'display-message "Yes"'
'display-message "No"'

works. Now the question shifts to how can I tell tmux to use a certain
shell? I guess I could provide multiple stanzas, one for bash and one for
dash, but that seems like a bad approach and can get unwieldy very quickly.

Any suggestions?

Thanks,
Robert LeBlanc
Robert LeBlanc
2015-03-26 06:45:02 UTC
Permalink
Robert LeBlanc

Sent from a mobile device please excuse any typos.
Post by Robert LeBlanc
Post by Robert LeBlanc
Post by Benoit Pierre
Post by Robert LeBlanc
I'm trying to make my .tmux.conf work for both 1.8 and 1.9 while
depreciating the old syntax. I can't get 1.9 (from Debian) or 1.9a (compiled
if-shell "[[ `/usr/bin/tmux -V` = *1.9* ]]" "display-message 'Yes'"
"display-message 'No'"
I always get "No". If I open up tmux on CentOS7 with 1.8 and adjust the line
to test for 1.8, I get "Yes" as expected. I get "No" if I change it to 1.9.
So it is working just fine in 1.8.
Are you sure it's not due to different shells and the use of "[[ ]]"
instead of "[ ]" ?
Post by Robert LeBlanc
dash -c '[[ "`tmux -V`" = *2.0* ]]'; echo $?
dash: 1: [[: not found
127
Post by Robert LeBlanc
bash -c '[[ "`tmux -V`" = *2.0* ]]'; echo $?
0
Also, note the additional double quotes for the call to `tmux -V`.
Cheers,
My shell is bash, but I'm not sure if tmux executes in my shell or it's
own. I can't get dash to pass, and I don't see a need for the extra double
quotes in bash.
Post by Robert LeBlanc
Post by Robert LeBlanc
tmux 1.9
1
echo $?
Post by Robert LeBlanc
Post by Robert LeBlanc
0
0
I'm really at a loss. The CentOS box doesn't have dash, so if tmux is
specifically using that, then I can see it as being the problem, but I
would expect that it would us my shell.
Post by Robert LeBlanc
Post by Robert LeBlanc
Thanks,
Robert LeBlanc
echo $?
Post by Robert LeBlanc
0
if-shell '[ "`tmux -V`" = "tmux 1.9" ]' 'display-message "Yes"'
'display-message "No"'
Post by Robert LeBlanc
works. Now the question shifts to how can I tell tmux to use a certain
shell? I guess I could provide multiple stanzas, one for bash and one for
dash, but that seems like a bad approach and can get unwieldy very quickly.
Post by Robert LeBlanc
Any suggestions?
Thanks,
Robert LeBlanc
It's too late here. The above syntax is POSIX so it should work in bash
just fine. Duh.
Benoit Pierre
2015-03-26 06:41:54 UTC
Permalink
Post by Benoit Pierre
Post by Robert LeBlanc
I'm trying to make my .tmux.conf work for both 1.8 and 1.9 while
depreciating the old syntax. I can't get 1.9 (from Debian) or 1.9a (compiled
if-shell "[[ `/usr/bin/tmux -V` = *1.9* ]]" "display-message 'Yes'"
"display-message 'No'"
I always get "No". If I open up tmux on CentOS7 with 1.8 and adjust the line
to test for 1.8, I get "Yes" as expected. I get "No" if I change it to 1.9.
So it is working just fine in 1.8.
Are you sure it's not due to different shells and the use of "[[ ]]"
instead of "[ ]" ?
Post by Robert LeBlanc
dash -c '[[ "`tmux -V`" = *2.0* ]]'; echo $?
dash: 1: [[: not found
127
Post by Robert LeBlanc
bash -c '[[ "`tmux -V`" = *2.0* ]]'; echo $?
0
Also, note the additional double quotes for the call to `tmux -V`.
Cheers,
My shell is bash, but I'm not sure if tmux executes in my shell or it's own.
I can't get dash to pass, and I don't see a need for the extra double quotes
in bash.
Weird, I need those with my version of bash.
tmux 1.9
1
$?
0
0
I'm really at a loss. The CentOS box doesn't have dash, so if tmux is
specifically using that, then I can see it as being the problem, but I would
expect that it would us my shell.
The problem is neither "[[" or the use of '*' in the test is valid
bourne shell syntax, so it's really not portable, and after looking at
it with strace, it appears tmux is using /bin/sh (while my shell is
/bin/zsh).

I don't know for Debian, but on Ubuntu /bin/sh is linked to dash, and
to bash on Redhat.
Thanks,
Robert LeBlanc
--
A: Because it destroys the flow of conversation.
Q: Why is top posting dumb?
Nicholas Marriott
2015-03-26 07:26:33 UTC
Permalink
Does it work if you change the condition to:

case "`tmux -V`" in *1.9*) true;; *) false;; esac
Post by Robert LeBlanc
I'm trying to make my .tmux.conf work for both 1.8 and 1.9 while
depreciating the old syntax. I can't get 1.9 (from Debian) or 1.9a
if-shell "[[ `/usr/bin/tmux -V` = *1.9* ]]" "display-message 'Yes'"
"display-message 'No'"
I always get "No". If I open up tmux on CentOS7 with 1.8 and adjust the
line to test for 1.8, I get "Yes" as expected. I get "No" if I change it
to 1.9. So it is working just fine in 1.8.
Any idea why it's not working on 1.9 for me?
Thank you,
Robert LeBlanc
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Loading...