Skip to content

Commit

Permalink
rundev: fix shellcheck complaints; ask to restart on control-C; fix h…
Browse files Browse the repository at this point in the history
…andling SIGKILL
  • Loading branch information
matyasselmeci committed Mar 5, 2024
1 parent 4440597 commit afc240c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/rundev
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
#!/bin/bash
ask_yn () {
echo "$@"
while read; do
echo "$@" >&2
while read -r; do
case $REPLY in
[Yy]*) return 0;;
[Nn]*) return 1;;
*) echo "Enter yes or no";;
*) echo "Enter yes or no" >&2;;
esac
done
return 2 ## EOF
}

export FLASK_ENV=development
export FLASK_DEBUG=True
cd "$(dirname "$0")"
cd "$(dirname "$0")" || exit 1
while true; do
python3 app.py; ret=$?
if [[ $ret -eq 0 ]]; then
exit
elif [[ $ret -eq 130 ]]; then # control-C
exit 130
elif [[ $ret -eq 136 ]]; then # kill -9
exit 136
if ! ask_yn "Interrupted. Restart (y/n)? "; then
exit 130
fi
elif [[ $ret -eq 137 ]]; then # kill -9
echo >&2 "Killed!"
exit 137
else
if ! ask_yn "Exited with $ret. Retry (y/n)? "; then
exit $ret
Expand Down

0 comments on commit afc240c

Please sign in to comment.