Last change
on this file since e25ef8c was
4149d9d,
checked in by Thierry Delisle <tdelisle@…>, 7 years ago
|
replacing old repeat script with c program
|
-
Property mode set to
100755
|
File size:
551 bytes
|
Rev | Line | |
---|
[cc3e4d0] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | if [ $1 == "-h" -o $1 == "--help" ]; then |
---|
| 4 | echo "$(basename $0) [-s|-p] ITERATIONS COMMAND" |
---|
| 5 | exit |
---|
| 6 | fi |
---|
| 7 | |
---|
| 8 | ACTION=$1 |
---|
| 9 | ITERATION=$2 |
---|
| 10 | shift 2 |
---|
| 11 | |
---|
| 12 | _term() { |
---|
| 13 | echo "Caught SIGTERM signal!" |
---|
| 14 | kill -TERM "$child" 2>/dev/null |
---|
| 15 | exit |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | trap _term SIGTERM SIGINT |
---|
| 19 | |
---|
| 20 | for (( i = 0; i < ITERATION; i ++ )); do |
---|
| 21 | echo -ne "\r$i / $ITERATION" |
---|
[e1c1829] | 22 | $@ > /dev/null & |
---|
[cc3e4d0] | 23 | child=$! |
---|
| 24 | wait "$child" |
---|
| 25 | RET=$? |
---|
| 26 | if [ $RET -ne 0 ]; then |
---|
| 27 | echo "FAILURE: $RET @ $i" |
---|
| 28 | fi |
---|
| 29 | if [ $ACTION == "-s" -a $RET -ne 0 ]; then |
---|
| 30 | exit $RET |
---|
| 31 | fi |
---|
| 32 | done |
---|
| 33 | echo -ne "\r$ITERATION / $ITERATION" |
---|
| 34 | |
---|
| 35 | exit 0 |
---|
Note: See
TracBrowser
for help on using the repository browser.