* [PATCH] terminal: Fix tmux new-session on older tmux versions (<1.9)
@ 2021-04-08 18:09 pbbudny
2021-04-09 13:27 ` [OE-core] " Richard Purdie
0 siblings, 1 reply; 2+ messages in thread
From: pbbudny @ 2021-04-08 18:09 UTC (permalink / raw)
To: openembedded-core
`tmux new -c` fails on tmux older than 1.9, when that flag was added.
We can omit the flag for older versions of tmux, and the working
directory gets set even without it.
---
meta/lib/oe/terminal.py | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py
index a1daa2bed6..a7aaf3dfe1 100644
--- a/meta/lib/oe/terminal.py
+++ b/meta/lib/oe/terminal.py
@@ -163,7 +163,12 @@ class Tmux(Terminal):
# devshells, if it's already there, add a new window to it.
window_name = 'devshell-%i' % os.getpid()
- self.command = 'tmux new -c "{{cwd}}" -d -s {0} -n {0} "{{command}}"'.format(window_name)
+ self.command = 'tmux new -c "{{cwd}}" -d -s {0} -n {0} "{{command}}"'
+ if not check_tmux_version('1.9'):
+ # `tmux new-session -c` was added in 1.9;
+ # older versions fail with that flag
+ self.command = 'tmux new -d -s {0} -n {0} "{{command}}"'
+ self.command = self.command.format(window_name)
Terminal.__init__(self, sh_cmd, title, env, d)
attach_cmd = 'tmux att -t {0}'.format(window_name)
@@ -250,13 +255,18 @@ def spawn(name, sh_cmd, title=None, env=None, d=None):
except OSError:
return
+def check_tmux_version(desired):
+ vernum = check_terminal_version("tmux")
+ if vernum and LooseVersion(vernum) < desired:
+ return False
+ return vernum
+
def check_tmux_pane_size(tmux):
import subprocess as sub
# On older tmux versions (<1.9), return false. The reason
# is that there is no easy way to get the height of the active panel
# on current window without nested formats (available from version 1.9)
- vernum = check_terminal_version("tmux")
- if vernum and LooseVersion(vernum) < '1.9':
+ if not check_tmux_version('1.9'):
return False
try:
p = sub.Popen('%s list-panes -F "#{?pane_active,#{pane_height},}"' % tmux,
--
2.23.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [OE-core] [PATCH] terminal: Fix tmux new-session on older tmux versions (<1.9)
2021-04-08 18:09 [PATCH] terminal: Fix tmux new-session on older tmux versions (<1.9) pbbudny
@ 2021-04-09 13:27 ` Richard Purdie
0 siblings, 0 replies; 2+ messages in thread
From: Richard Purdie @ 2021-04-09 13:27 UTC (permalink / raw)
To: pbbudny, openembedded-core
On Thu, 2021-04-08 at 18:09 +0000, Budny, Peter via lists.openembedded.org wrote:
> `tmux new -c` fails on tmux older than 1.9, when that flag was added.
> We can omit the flag for older versions of tmux, and the working
> directory gets set even without it.
> ---
> meta/lib/oe/terminal.py | 16 +++++++++++++---
> 1 file changed, 13 insertions(+), 3 deletions(-)
Thanks for the patch, could you resend with a Signed-off-by line though
please?
Also, a minor tweak to the prefix in the shortlog to "lib/oe/terminal:"
would be great since it needs resending.
Cheers,
Richard
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-09 13:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 18:09 [PATCH] terminal: Fix tmux new-session on older tmux versions (<1.9) pbbudny
2021-04-09 13:27 ` [OE-core] " Richard Purdie
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.