How can calling “exit 1” result in an infinite loop?
That rather suggests that we are never getting to that part of the code. Should we not rather fix this?
Having a catchall at the end of a script is a standard pattern and keeps the script easier to extend if new options are being added because you cannot forget to add them to the top?
-Michael
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
If we check this at the end, we already do some calculation in the next line. For example checking if the devices are correct. This is not necessary as we can already stop when we get an "stoop" or something like:
/etc/init.d/network green stop
This currently ends in an infinite loop, which gets fixed by this change.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
src/initscripts/system/network | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 9694165f2..06240f53c 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -26,6 +26,11 @@ eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) DO="${1}" shift
+if ! [[ "${DO}" == "start" || "${DO}" == "restart" || "${DO}" == "stop" ]]; then
- echo "Usage: ${0} {start|stop|restart} [device(s)]"
- exit 1
+fi
if [ -n "${1}" ]; then ALL=0 for i in green red blue orange; do @@ -100,9 +105,4 @@ case "${DO}" in sleep 1 ${0} start ${ARGS} ;;
- *)
- echo "Usage: ${0} {start|stop|restart} [device(s)]"
- exit 1
- ;;
esac
2.30.2