Add existing scripts

This commit is contained in:
chris committed 2026-09-29 15:24:09 -04:00
1 parent 2ab5a42c2b
commit 3c05d74104
31 files changed
+1138

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# An example of how to ensure a user really wants to interrupt an operation
# Useful for scripts where interruption could be harmful
interrupt_count=0
on_interrupt() {
if [ $interrupt_count -lt 1 ]; then
echo "Canceling this operation can cause errors."
echo "Press Ctrl-C again if you are sure you want to cancel."
interrupt_count=$((interrupt_count + 1))
else
# Convention is to use the status code 130 for interrupted scripts.
echo "Canceling long operation"
printf "$(tput cr)$(tput el)"
exit 130
fi
}
trap on_interrupt INT
total_time=0
while [ $total_time -le 600 ]; do
printf "$(tput cr)$(tput el)Long operation: ${total_time} seconds elapsed\r"
sleep 3
total_time=$((total_time + 3))
done