Fix status detection on running cmd with set input or cmd containing special chars

This commit is contained in:
Ilia Rostovtsev
2021-03-06 17:33:38 +03:00
parent 8a8abf2ee5
commit 72f4a33d84

View File

@@ -1406,7 +1406,19 @@ else {
$eos = '$';
}
}
($proc) = grep { $_->{'args'} =~ /\Q$cmd\E$eos/ &&
# If `Input to command` is set, remove it for test case
# otherwise cmd will always be displayed as not running
my $cmd_ = $cmd;
# First remove only input to command and preserve
# potential arguments containing escaped %, like \\%
$cmd_ =~ s/(?<!\\)%.*//;
# Now replace escaped \\ special chars for testing purposes
$cmd_ =~ s/\\//g;
($proc) = grep { $_->{'args'} =~ /\Q$cmd_\E$eos/ &&
(!$config{'match_user'} || $_->{'user'} eq $_[0]->{'user'}) }
@procs;
if (!$proc && $cmd =~ /^$config_directory\/(.*\.pl)(.*)$/) {