Question 90
The lab examiner asks for evidence after this assignment: A housekeeping script must print each user-provided directory rather than always print one hard-coded value. What is the decisive verification step?
Explanation
Correct Answer
Arguments containing spaces are printed as single intended entries and the loop count matches input count. This check confirms the expected effect of: Use `for dir in "$@"; do printf '%s\n' "$dir"; done` with arguments supplied at invocation. It distinguishes the intended result from the original failure mechanism: Quoting `"$@"` preserves positional argument boundaries for safe shell iteration.
Incorrect Answers
The file `/tmp/lab reports/status.txt` receives the line and no extra files are created. That verifies a separate lab task: A training script appends to a log whose path includes spaces and breaks because the variable is expanded unquoted. It does not validate the implementation required here: Use `for dir in "$@"; do printf '%s\n' "$dir"; done` with arguments supplied at invocation.
Known values 9 and 10 route to different expected branches. That verifies a separate lab task: A script's `if` statement tests a numeric threshold using string comparison and misorders the values 9 and 10. It does not validate the implementation required here: Use `for dir in "$@"; do printf '%s\n' "$dir"; done` with arguments supplied at invocation.
The printed host label matches `hostname -s` without treating it as an executable. That verifies a separate lab task: A shell script writes raw command output but needs its first line to include the current hostname from the target host. It does not validate the implementation required here: Use `for dir in "$@"; do printf '%s\n' "$dir"; done` with arguments supplied at invocation.