mirror of
https://github.com/SCST-project/scst.git
synced 2026-09-26 01:44:54 +00:00
scripts: Validate monitor intervals
Reject zero and nonnumeric sampling intervals before entering the monitor loops, avoiding division errors and repeated failed sleep calls.
This commit is contained in:
@@ -2,6 +2,12 @@
|
||||
|
||||
interval="${1:-5}"
|
||||
|
||||
if ! [[ "$interval" =~ ^0*[1-9][0-9]*$ ]]; then
|
||||
echo "Error: interval must be a positive integer." >&2
|
||||
exit 1
|
||||
fi
|
||||
interval="${interval#"${interval%%[!0]*}"}"
|
||||
|
||||
echo "Interrupts per second:"
|
||||
while true
|
||||
do
|
||||
|
||||
Reference in New Issue
Block a user