Question 290
In a hands-on RHCSA practice VM, the assigned outcome was: A training script appends to a log whose path includes spaces and breaks because the variable is expanded unquoted. What specific verification would demonstrate the target state?
Explanation
Correct Answer
The file `/tmp/lab reports/status.txt` receives the line and no extra files are created. This check confirms the expected effect of: Use `printf '%s\n' "$message" >> "$log_path"` with a quoted destination variable. It distinguishes the intended result from the original failure mechanism: Unquoted shell variable expansion performs splitting and pathname expansion.
Incorrect Answers
The script runs under a restricted environment and resolves required binaries. That verifies a separate lab task: A cron-invoked script prints `command not found` for a utility present in the interactive user's shell. It does not validate the implementation required here: Use `printf '%s\n' "$message" >> "$log_path"` with a quoted destination variable.
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 `printf '%s\n' "$message" >> "$log_path"` with a quoted destination variable.
The resulting filename contains the current date digits and `tar -tzf` lists expected members. That verifies a separate lab task: A script generates a timestamped training archive but literal quotes around the `date` substitution prevent expansion. It does not validate the implementation required here: Use `printf '%s\n' "$message" >> "$log_path"` with a quoted destination variable.