Question 340
A local .sh file has the right shebang but produces a permission error when executed as ./run.sh. One student proposes Run chmod u+x run.sh for its owner and another proposes Use read -r answer. Which technical comparison is the soundest?
Explanation
Correct Answer
Correct distinction: Run chmod u+x run.sh for its owner targets make script executable; The execute permission allows direct execution when the filesystem permits it. The compared alternative instead serves read terminal input safely.
Incorrect Answers
Incorrect mapping: Use read -r answer is used for read terminal input safely. It does not displace Run chmod u+x run.sh for its owner for the described requirement.
The mechanisms are different: The execute permission allows direct execution when the filesystem permits it. By contrast, The -r flag prevents read from treating backslashes as escape characters. They are not universally interchangeable.
The third option addresses capture command output: Command substitution runs the command and substitutes its standard output. The original action remains relevant because The execute permission allows direct execution when the filesystem permits it.