Question 210
Before approving this basic Linux procedure, the team observes: A student creates a directory named My Reports and then runs a command using the unquoted path, causing Bash to treat its two words as separate arguments. What ongoing quality or security safeguard is most appropriate?
Explanation
Correct Answer
This safeguard addresses double quotes preserve path spaces in shell arguments: Test shell scripts with whitespace-containing filenames and avoid assembling unquoted file paths from external input. The prevented failure mechanism is: Shell word splitting treats unquoted spaces as argument separators; appropriate quoting preserves a path containing spaces as one parameter. A control for an unrelated service cannot establish the required protection.
Incorrect Answers
Bash can maintain an in-session command history, and persistent history behavior depends on shell configuration and session lifecycle. “Avoid typing passwords or tokens into interactive commands because shell history may retain sensitive parameters” would remedy that alternative situation, but it would not correct the present issue: shell word splitting treats unquoted spaces as argument separators; appropriate quoting preserves a path containing spaces as one parameter.
“Test environment visibility in child processes rather than assuming a local shell variable automatically becomes globally available” is the supported response when an ordinary shell variable is scoped to the current shell, while exported environment variables are passed to child processes. Here the decisive response is “Test shell scripts with whitespace-containing filenames and avoid assembling unquoted file paths from external input”, so that different intervention does not meet the stated requirement.
An interactive shell interprets typed command lines and can launch built-ins or available executables without compiling the command text into a program. “Distinguish interactive commands from scripts and compiled programs when diagnosing why a simple shell instruction will not run” applies to that other condition. The reported evidence is a student creates a directory named My Reports and then runs a command using the unquoted path, causing Bash to treat its two words as separate arguments; this alternative would address the wrong dependency.