parallel: --tmux uses args as window name.

This commit is contained in:
Ole Tange 2014-07-19 00:50:48 +02:00
parent 81ff568ce7
commit 5372383da2
4 changed files with 30 additions and 16 deletions

View file

@ -1 +1,4 @@
SUBDIRS = src SUBDIRS = src
test:
cd testsuite; make 1

View file

@ -697,6 +697,9 @@ uninstall-am:
uninstall uninstall-am uninstall uninstall-am
test:
cd testsuite; make 1
# Tell versions [3.59,3.63) of GNU make to not export all variables. # Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded. # Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT: .NOEXPORT:

View file

@ -216,9 +216,9 @@ cc:Tim Cuthbertson <tim3d.junk@gmail.com>,
Ryoichiro Suzuki <ryoichiro.suzuki@gmail.com>, Ryoichiro Suzuki <ryoichiro.suzuki@gmail.com>,
Jesse Alama <jesse.alama@gmail.com> Jesse Alama <jesse.alama@gmail.com>
Subject: GNU Parallel 20140722 ('Eyal Gilad Naftali') released Subject: GNU Parallel 20140722 ('MH17') released
GNU Parallel 20140722 ('Eyal Gilad Naftali') has been released. It is available for download at: http://ftp.gnu.org/gnu/parallel/ GNU Parallel 20140722 ('MH17') has been released. It is available for download at: http://ftp.gnu.org/gnu/parallel/
This release contains a major change in central parts of the code and should be considered beta quality. As always it passes the testsuite, so most functionality clearly works. This release contains a major change in central parts of the code and should be considered beta quality. As always it passes the testsuite, so most functionality clearly works.

View file

@ -5220,7 +5220,7 @@ sub start {
(cat $tmpfile; rm $tmpfile; cat - ) | } . (cat $tmpfile; rm $tmpfile; cat - ) | } .
"($command);"; "($command);";
if($opt::tmux) { if($opt::tmux) {
$command = tmux_wrap($command,$job->replaced()); $command = $job->tmux_wrap($command);
} }
# The eval is needed to catch exception from open3 # The eval is needed to catch exception from open3
@ -5237,7 +5237,8 @@ sub start {
*IN = *STDIN; *IN = *STDIN;
# The eval is needed to catch exception from open3 # The eval is needed to catch exception from open3
if($opt::tmux) { if($opt::tmux) {
$command = tmux_wrap($command,$job->replaced()); $command = $job->tmux_wrap($command);
# $command = tmux_wrap($command,$job->replaced());
} }
eval { eval {
$pid = ::open3("<&IN", ">&OUT", ">&ERR", $ENV{SHELL}, "-c", $command) || $pid = ::open3("<&IN", ">&OUT", ">&ERR", $ENV{SHELL}, "-c", $command) ||
@ -5253,7 +5254,8 @@ sub start {
*IN = $devtty_fh; *IN = $devtty_fh;
# The eval is needed to catch exception from open3 # The eval is needed to catch exception from open3
if($opt::tmux) { if($opt::tmux) {
$command = tmux_wrap($command,$job->replaced()); $command = $job->tmux_wrap($command);
# $command = tmux_wrap($command,$job->replaced());
} }
eval { eval {
$pid = ::open3("<&IN", ">&OUT", ">&ERR", $ENV{SHELL}, "-c", $command) || $pid = ::open3("<&IN", ">&OUT", ">&ERR", $ENV{SHELL}, "-c", $command) ||
@ -5264,7 +5266,8 @@ sub start {
}; };
} else { } else {
if($opt::tmux) { if($opt::tmux) {
$command = tmux_wrap($command,$job->replaced()); $command = $job->tmux_wrap($command);
# $command = tmux_wrap($command,$job->replaced());
} }
eval { eval {
$pid = ::open3(::gensym, ">&OUT", ">&ERR", $ENV{SHELL}, "-c", $command) || $pid = ::open3(::gensym, ">&OUT", ">&ERR", $ENV{SHELL}, "-c", $command) ||
@ -5296,30 +5299,35 @@ sub tmux_wrap {
# Wrap command with tmux for session pPID # Wrap command with tmux for session pPID
# Input: # Input:
# $actual_command = the actual command being run (incl ssh wrap) # $actual_command = the actual command being run (incl ssh wrap)
# $visual_command = the command the user wants run (= -v) my $self = shift;
my $actual_command = shift; my $actual_command = shift;
my $visual_command = shift;
# Temporary file name. Used for fifo to communicate exit val # Temporary file name. Used for fifo to communicate exit val
my ($fh, $tmpfile) = ::tempfile(SUFFIX => ".tmx"); my ($fh, $tmpfile) = ::tempfile(SUFFIX => ".tmx");
$Global::unlink{$tmpfile}=1;
close $fh; close $fh;
unlink $tmpfile; unlink $tmpfile;
my $c = $visual_command; my $visual_command = $self->replaced();
# tmux does not like some chars (e.g. ;). my $c = ::undef_as_empty($self->{'commandline'}->replace_placeholders(["\257<\257>"],0,0))."";
$c =~ s/[^-<>(),:_+=#a-z0-9 `\\\$\|]//g; # ascii 194-224 annoys tmux
$c =~ s/[\011-\016;\302-\340]//g;
my $tmux; my $tmux;
if($Global::total_running == 0) { if($Global::total_running == 0) {
$tmux = "tmux new-session -s p$$ -d -n ". $tmux = "tmux new-session -s p$$ -d -n ".
::shell_quote_scalar($c); ::shell_quote_scalar($c);
print $Global::original_stderr "See output with: tmux attach -t p$$\n"; print $Global::original_stderr "See output with: tmux attach -t p$$\n";
} else { } else {
$tmux = "tmux new-window -t p$$ -n ".::shell_quote_scalar($c); $tmux = "tmux new-window -t p$$ -n ".::shell_quote_scalar($c);
} }
# $tmux = "tmux new-session -s p$$ -d true >/dev/null; ".
# "tmux new-window -t p$$ -n ".::shell_quote_scalar($c);
return "mkfifo $tmpfile; $tmux ". return "mkfifo $tmpfile; $tmux ".
::shell_quote_scalar("(".$actual_command.');echo $?$status >'.$tmpfile.";". # Run in tmux
::shell_quote_scalar("(".$actual_command.');(echo $?$status;echo 255) >'.$tmpfile.";".
"echo ".::shell_quote_scalar($visual_command).";". "echo ".::shell_quote_scalar($visual_command).";".
"echo \007Job finished at: `date`;sleep 60"). "echo \007Job finished at: `date`;sleep 10").
"; ( exit `cat < $tmpfile;rm $tmpfile` )"; # Run outside tmux
"; exit `perl -ne '1..1 and print' $tmpfile;rm $tmpfile` ";
} }
sub is_already_in_results { sub is_already_in_results {