Discussion:
run-shell error on while-loop
C***@thekyel.com
2014-12-22 18:09:54 UTC
Permalink
I've got a weird issue where running a script with "run-shell" acts differently than running it from my actual shell.
bind-key -n "M-B" run-shell "/bin/bash /usr/bin/test.sh"
#!/bin/bash
lockfile="/tmp/.tmux.lock"
touch "${lockfile}"
tmux choose-buffer "paste-buffer -b '%%' ; run-shell \"rm ${lockfile}\""
while [ -f "${lockfile}" ]
do
sleep 1
done
touch "/tmp/.paste.done"
If I run the script from my shell, it works fine. The lock-file gets created, and then removed. The "/tmp/.paste.done" file is also created.

If, however, I run the script using my key-binding above, I get an error on line 4.
The paste-buffer will paste, but the lock-file is never removed.

One weird thing I've figured out, is that if I remove the while-loop on lines 5-8, the script works no matter how I call it.

Any other thoughts/ideas on how to troubleshoot or debug this?

-- Kyel
Nicholas Marriott
2014-12-23 09:55:43 UTC
Permalink
tmux version?

-------- Original message --------
From: ***@thekyel.com
Date:22/12/2014 18:09 (GMT+00:00)
To: tmux-***@lists.sf.net
Subject: run-shell error on while-loop

I've got a weird issue where running a script with "run-shell" acts differently than running it from my actual shell.
  bind-key -n "M-B" run-shell "/bin/bash /usr/bin/test.sh"
  #!/bin/bash
  lockfile="/tmp/.tmux.lock"
  touch "${lockfile}"
  tmux choose-buffer "paste-buffer -b '%%' ; run-shell \"rm ${lockfile}\""
  while [ -f "${lockfile}" ]
  do
      sleep 1
  done
  touch "/tmp/.paste.done"
If I run the script from my shell, it works fine. The lock-file gets created, and then removed. The "/tmp/.paste.done" file is also created.

If, however, I run the script using my key-binding above, I get an error on line 4.
The paste-buffer will paste, but the lock-file is never removed.

One weird thing I've figured out, is that if I remove the while-loop on lines 5-8, the script works no matter how I call it.

Any other thoughts/ideas on how to troubleshoot or debug this?

  -- Kyel
Nicholas Marriott
2014-12-23 15:16:32 UTC
Permalink
Your choose-buffer commands will run in the same session as your key
binding but that session's command queue is blocked waiting for the
first run-shell to exit. Bind the key to run-shell -b instead.
tmux 1.9
-- Kyel
Post by Nicholas Marriott
tmux version?
-------- Original message --------
Date:22/12/2014 18:09 (GMT+00:00)
Subject: run-shell error on while-loop
I've got a weird issue where running a script with "run-shell" acts differently
than running it from my actual shell.
bind-key -n "M-B" run-shell "/bin/bash /usr/bin/test.sh"
#!/bin/bash
lockfile="/tmp/.tmux.lock"
touch "${lockfile}"
tmux choose-buffer "paste-buffer -b '%%' ; run-shell \"rm ${lockfile}\""
while [ -f "${lockfile}" ]
do
sleep 1
done
touch "/tmp/.paste.done"
If I run the script from my shell, it works fine. The lock-file gets created,
and then removed. The "/tmp/.paste.done" file is also created.
If, however, I run the script using my key-binding above, I get an error on line 4.
The paste-buffer will paste, but the lock-file is never removed.
One weird thing I've figured out, is that if I remove the while-loop on lines
5-8, the script works no matter how I call it.
Any other thoughts/ideas on how to troubleshoot or debug this?
-- Kyel
------------------------------------------------------------------------------
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
C***@thekyel.com
2014-12-23 17:23:13 UTC
Permalink
Hey! works like magic. I guess I thought that if I ran it in the background, that I'd never see the choose-buffer.
Thanks!

-- Kyel
Post by Nicholas Marriott
Your choose-buffer commands will run in the same session as your key
binding but that session's command queue is blocked waiting for the
first run-shell to exit. Bind the key to run-shell -b instead.
tmux 1.9
-- Kyel
Post by Nicholas Marriott
tmux version?
-------- Original message --------
Date:22/12/2014 18:09 (GMT+00:00)
Subject: run-shell error on while-loop
I've got a weird issue where running a script with "run-shell" acts differently
than running it from my actual shell.
bind-key -n "M-B" run-shell "/bin/bash /usr/bin/test.sh"
#!/bin/bash
lockfile="/tmp/.tmux.lock"
touch "${lockfile}"
tmux choose-buffer "paste-buffer -b '%%' ; run-shell \"rm ${lockfile}\""
while [ -f "${lockfile}" ]
do
sleep 1
done
touch "/tmp/.paste.done"
If I run the script from my shell, it works fine. The lock-file gets created,
and then removed. The "/tmp/.paste.done" file is also created.
If, however, I run the script using my key-binding above, I get an error on line 4.
The paste-buffer will paste, but the lock-file is never removed.
One weird thing I've figured out, is that if I remove the while-loop on lines
5-8, the script works no matter how I call it.
Any other thoughts/ideas on how to troubleshoot or debug this?
-- Kyel
------------------------------------------------------------------------------
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...