Question 320
A script needs to request Bash as its interpreter when executed directly. One student proposes Place #!/bin/bash as the first line of the script and another proposes Forward arguments using "$@". Which technical comparison is the soundest?
Explanation
Correct Answer
Correct distinction: Place #!/bin/bash as the first line of the script targets Bash interpreter shebang; The shebang tells the operating system which interpreter to use for direct execution. The compared alternative instead serves preserve multiple arguments.
Incorrect Answers
Incorrect mapping: Forward arguments using "$@" is used for preserve multiple arguments. It does not displace Place #!/bin/bash as the first line of the script for the described requirement.
The mechanisms are different: The shebang tells the operating system which interpreter to use for direct execution. By contrast, Double-quoted $@ expands to separate arguments while preserving each argument's boundaries. They are not universally interchangeable.
The third option addresses iterate over filenames: A for loop repeats the body for each word or list element. The original action remains relevant because The shebang tells the operating system which interpreter to use for direct execution.