Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
a simple shell script:
#!/bin/sh str="hello" while [ -n $str ]; do #do noting, just loop infinitely done
this script throws an error, like this:
./while.sh: 5: ./while.sh: Syntax error: "done" unexpected
why, and what is the correct way ?
You need to do something! The shortest thing you can do is this:
do
#!/bin/sh str="hello" while [ -n "$str" ]; do : done
:, a shorthand for true, does nothing and returns success.
:
true
By the way, I quoted your string $str, as this is something that you should always do.
$str
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.