init-script-template icon indicating copy to clipboard operation
init-script-template copied to clipboard

stop for loop

Open gregorko opened this issue 10 years ago • 5 comments

I think in Bourne shell the loop for i in {1..10} is not working. At least for me it only goes through once and causes the stop to not wait long enough. Other scripts I looked at tend to use other type of loops.

gregorko avatar Feb 03 '15 08:02 gregorko

Same problem here. It's got #!/bin/sh at the top of the script but init v or whatever is running it using bash. Any idea what type of loop we should use instead?

dgrant avatar Apr 17 '15 16:04 dgrant

I replaced line 47 to line 57 with:

kill `get_pid`
i=0
while is_running; do
  if [ $i = '60' ]; then
    break;
  else
    echo -n "."
    i=$(($i+1))
    sleep 1
  fi
done
echo

Also I raised the max waiting time to 60 seconds

gregorko avatar Apr 17 '15 21:04 gregorko

hehe, I did something similar

dgrant avatar Apr 17 '15 21:04 dgrant

(and then I call kill -9 if it still doesn't die)

dgrant avatar Apr 17 '15 21:04 dgrant

It is Bourne shell, so I used for i in 1 2 3 4 5 6 7 8 9 instead of for i in {1..10} http://steve-parker.org/sh/loops.shtml

PLG avatar Jun 30 '15 21:06 PLG