0

Hi All,
I want to know if there is any way to exit from both the parent and child loop simultaneously without adding any kind of conditional statement.
********************************************************
#!bin/ksh
a=5
if[[ $a -gt 5 ]]
then
echo "a=5 and not went to else cdn."
else
if [[ $a==5 ]]
then
echo "a=6"
fi
echo "a=5 and not worked"
fi
echo "got it"
********************************************************
Once the program prints "a=6" it should print "got it".
Will any thing work here without going for label,goto command.
I tried with break but it din't work at all.
Please suggesst me your views.

/Nandoo.

3
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by jim mcnamara
1

Hmm... not exactly sure because I program in a structured language (C++). I definitely agree that you shouldn't use a GOTO command.

I think you should use a switch or while statement, and then break when you're done. This would allow you to keep "structured" programming, while avoiding the GOTO statement.

1

Your logic doesn't make any sense to me...

You want to get to the "got it" statement - this does it.

#!bin/ksh
a=5
while [[ $a -gt 5 ]]
do
	echo "a=5 and not went to else cdn."

	if [[ $a==5 ]]
	then
		echo "a=6" 
	fi
	echo "a=5 and not worked" 
done
echo "got it"
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.