mirror of
https://github.com/vale981/ray
synced 2025-03-04 17:41:43 -05:00

* Fix SC2001: See if you can use ${variable//search/replace} instead. * Fix SC2010: Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames. * Fix SC2012: Use find instead of ls to better handle non-alphanumeric filenames. * Fix SC2015: Note that A && B || C is not if-then-else. C may run when A is true. * Fix SC2028: echo may not expand escape sequences. Use printf. * Fix SC2034: variable appears unused. Verify use (or export if used externally). * Fix SC2035: Use ./*glob* or -- *glob* so names with dashes won't become options. * Fix SC2071: > is for string comparisons. Use -gt instead. * Fix SC2154: variable is referenced but not assigned * Fix SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. * Fix SC2188: This redirection doesn't have a command. Move to its command (or use 'true' as no-op). * Fix SC2236: Use -n instead of ! -z. * Fix SC2242: Can only exit with status 0-255. Other data should be written to stdout/stderr. * Fix SC2086: Double quote to prevent globbing and word splitting. Co-authored-by: Mehrdad <noreply@github.com>
33 lines
633 B
Bash
Executable file
33 lines
633 B
Bash
Executable file
#!/bin/bash
|
|
# Run a command, suppressing output unless it hangs or crashes.
|
|
|
|
TMPFILE="$(mktemp)"
|
|
PID=$$
|
|
|
|
# Print output to avoid travis killing us
|
|
watchdog() {
|
|
for i in $(seq 5 5 150); do
|
|
sleep 300
|
|
echo "This command has been running for more than $i minutes..."
|
|
done
|
|
echo "Command timed out after 2.5h, dumping logs:"
|
|
cat "$TMPFILE"
|
|
echo "TIMED OUT"
|
|
kill -SIGKILL $PID
|
|
}
|
|
|
|
watchdog 2>/dev/null &
|
|
WATCHDOG_PID=$!
|
|
|
|
time "$@" >"$TMPFILE" 2>&1
|
|
|
|
CODE=$?
|
|
if [ $CODE != 0 ]; then
|
|
tail -n 2000 "$TMPFILE"
|
|
echo "FAILED $CODE"
|
|
kill $WATCHDOG_PID
|
|
exit $CODE
|
|
fi
|
|
|
|
kill $WATCHDOG_PID
|
|
exit 0
|