Question 370
In a hands-on RHCSA practice VM, the assigned outcome was: A script asks users for a name but accidentally treats backslash sequences in the input as control codes. What specific verification would demonstrate the target state?
Explanation
Correct Answer
A fixture containing backslashes is printed unchanged and no unexpected interpolation occurs. This check confirms the expected effect of: Use `IFS= read -r name` and `printf '%s\n' "$name"` to preserve literal input. It distinguishes the intended result from the original failure mechanism: `read` without `-r` can treat backslashes as escapes.
Incorrect Answers
Only directory entries appear while ordinary files are skipped. That verifies a separate lab task: A daily job must print only directories under a sample tree but currently loops through both files and directories. It does not validate the implementation required here: Use `IFS= read -r name` and `printf '%s\n' "$name"` to preserve literal input.
Arguments containing spaces are printed as single intended entries and the loop count matches input count. That verifies a separate lab task: A housekeeping script must print each user-provided directory rather than always print one hard-coded value. It does not validate the implementation required here: Use `IFS= read -r name` and `printf '%s\n' "$name"` to preserve literal input.
A simulated directory creation failure stops the script before any misleading success message. That verifies a separate lab task: A backup script runs even when its destination directory cannot be created, silently losing its output. It does not validate the implementation required here: Use `IFS= read -r name` and `printf '%s\n' "$name"` to preserve literal input.