Question 130
In a hands-on RHCSA practice VM, the assigned outcome was: A shell script receives `source` and `destination` as positional parameters and currently copies an empty path when arguments are missing. What specific verification would demonstrate the target state?
Explanation
Correct Answer
Two valid paths work and calling with only one argument returns exit code 2 without copying. This check confirms the expected effect of: Check `[ "$#" -eq 2 ] || exit 2` and use quoted `"$1"` and `"$2"` in the copy command. It distinguishes the intended result from the original failure mechanism: Positional parameters may be absent or contain spaces, requiring validation and quoting.
Incorrect Answers
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: Check `[ "$#" -eq 2 ] || exit 2` and use quoted `"$1"` and `"$2"` in the copy command.
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: Check `[ "$#" -eq 2 ] || exit 2` and use quoted `"$1"` and `"$2"` in the copy command.
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: Check `[ "$#" -eq 2 ] || exit 2` and use quoted `"$1"` and `"$2"` in the copy command.