So I have this If statement that checks what the exit code of the script is:
if [ $? -eq 0 ]; then
wasSuccessful=true;
fi
In other languages, I would do something like:
while wasSuccessful == false
And then the loop would keep running until the exit code was true. (I plan to implement a loop counter as well for too many failed attempts, but that's a different problem to solve)
I think I need a here-string, but I'm not exactly sure how that would look. Here's a rough outline of my code right now, in Bash:
wasSuccessful=false
while [ "$wasSuccessful" = "false" ]
do
#Bunch of code here, then the check for exit code
if [ $? -eq 0 ]; then
wasSuccessful=true;
fi
done
Any suggestions on how to do something like this would be much appreciated :)
while loopnot executed in subshell, unless you put them inside quote(commands).whileloop, and things involved in a pipeline are run in subshells. So if you did, say,getent passwd user_prefix | while read -r ent; do...then that loop would be in a subshell, as written yours would not create a subshell