run-this-one does not match shell scripts (using pgrep)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
run-one (Ubuntu) |
Fix Released
|
Medium
|
Dustin Kirkland |
Bug Description
I have the following shell script, which does not work properly with `run-this-one`:
#!/usr/bin/zsh -i
#
# Execute a given command on the first reachable host
#
# Syntax: on_first_host 'cmd %s' hostA hostB
on_first_host() {
cmd=$1
shift
for host; do
echo "Trying $host..."
ping -c1 -w2 -q $host > /dev/null || continue
$(printf $cmd $host)
return
done
}
on_first_host "$@"
When called like this, the first pgrep in the "run-this-one" case will not find the running process:
run-this-one on_first_host 'foo %s' foobar boobaz
The second try, using lsof appears to find the matching progress, but when using "ssh" as a command for "on_first_host", the "sleep 0.1" appears to be too short (the ssh process is still running), and the following "flock" command fails.
Committed revision 37.