Question 330
A Linux user needs to resolve this problem: A deployment script reads a filename containing spaces from a variable and invokes a command without quoting the expansion. Which observation would BEST verify that the problem was resolved?
Explanation
Correct Answer
A sample path with spaces is processed as a single file without unintended extra operands. This is specific evidence for the stated requirement. The explanation is: Unquoted parameter expansion can undergo word splitting and pathname expansion before the command receives it. The required action is: Quote the shell expansion as "$file" so one filename is passed as one argument.
Incorrect Answers
This test can succeed without resolving the cause described here. It addresses: A terminal text editor has its own shortcuts; writing a buffer and exiting are distinct operations. The relevant causal dependency is: Unquoted parameter expansion can undergo word splitting and pathname expansion before the command receives it. The required validation is “A sample path with spaces is processed as a single file without unintended extra operands”.
The alternative measures an outcome associated with: The shell stops processing a script when exit is executed, regardless of later lines in the file. It does not verify the stated failure. Here unquoted parameter expansion can undergo word splitting and pathname expansion before the command receives it. Confirm “A sample path with spaces is processed as a single file without unintended extra operands”.
That observation would verify a different mechanism: The quoted $@ expansion represents each positional argument as a distinct shell word. It would not establish whether the present failure was corrected, because unquoted parameter expansion can undergo word splitting and pathname expansion before the command receives it. Test “A sample path with spaces is processed as a single file without unintended extra operands” instead.