Free LPI 702-100 Actual Exam Questions - Question 6 Discussion
Not B, it misses spaces inside brackets which Bourne shell needs.
D imo, because the classic Bourne shell requires spaces around the square brackets and proper use of test commands. Looking at the options, D seems to follow the right syntax with spaces and a valid test expression, unlike C which uses double brackets that aren’t supported. A and B either miss spaces or have syntax quirks that would cause errors in a strict Bourne shell environment. So, if this is about original Bourne shell syntax only, D is the safest bet.
I’m ruling out C because it uses double brackets, which isn’t valid in the original Bourne shell. B stands out since it uses single brackets with spaces, matching the classic syntax better. Does anyone think double brackets could be allowed here?
It’s definitely not A or D since those use double brackets, which Bourne shell doesn’t support. Between B and C, B stands out because it uses the test command inside single brackets with proper spacing, which is the classic Bourne shell syntax. C seems to mix spaces oddly or use more Bash-like syntax. So B fits best as a valid if condition in the original Bourne shell environment.
I think option A works too because it uses the classic test command format without extra spaces that might confuse the shell. The Bourne shell is pretty strict about spacing and syntax, so anything with double brackets or missing spaces is usually out. This one sticks to the basics, which makes it valid for Bourne shell if conditions.
It’s B. The syntax with single brackets and spaces around them is standard for Bourne shell, unlike double brackets which are more Bash-specific. That makes B the safer choice here.
Since it's about valid if syntax in Bourne shell, I’d go with C. The others look off with missing spaces or wrong use of brackets.