2. |
Which of the following lines of code does not contain a syntax error?
Please select the best answer.
|
|
A. |
if [ $answer = 'yes' ]
then
echo 'yahoo'
fi
|
|
B. |
if [ $answer ='yes' ]
then
echo 'yahoo'
fi
|
|
C.
|
while [ '$answer' = 'yes' ]
echo 'yahoo'
done
|
|
D.
|
while ['$answer' = yes' ]
do
echo 'yahoo'
done
|
|
Answer A is correct; this statement has no syntax errors. Answer B is incorrect because there is no space after the equal sign.
Answer C is incorrect because it is missing the keyword do. Answer D is incorrect because there is no space after the opening square bracket.
|