Reputation: 1931
For a specific reason I have to do an infinite loop inside a function and then run the function as a daemon,
#!/bin/sh
lol(){
while true
do
echo "looping..."
sleep 2
done
}
lol() &
that script doesn't work, it gives me the following error:
/tmp/test: line 9: syntax error: unexpected "&"
How do I do an infinite loop inside a function in ash
?
Upvotes: 4
Views: 9115
Reputation: 295687
You're just starting the function wrong -- it's nothing to do with the loop:
lol &
Parenthesis are used only at function definition time, not for invocation.
Upvotes: 3