LFCS · Question #460
You are looking into a new script you received from your senior administrator. In the very first line you notice a #! followed by a path to a binary. The shell will ...
The correct answer is B. use that binary to interpret the script. The #! (shebang) line at the beginning of a script tells the operating system which interpreter binary to use for executing the script.
Question
Options
- Aignore the script
- Buse that binary to interpret the script
- Cuse that binary to compile the script
- Dbe replaced by that binary
How the community answered
(44 responses)- A2% (1)
- B93% (41)
- C5% (2)
Why each option
The `#!` (shebang) line at the beginning of a script tells the operating system which interpreter binary to use for executing the script.
The shell does not ignore the script; the shebang line explicitly instructs the kernel on how to execute it.
The `#!` (shebang) line at the beginning of a script specifies the interpreter program that should be used to execute the script. When the script is run, the operating system's kernel reads this line and invokes the specified binary, passing the script's path as an argument for interpretation.
The specified binary is used to *interpret* the script, not compile it, unless the binary itself is a compiler, which is not the primary purpose of the shebang.
The shell itself doesn't get replaced; rather, the kernel launches the specified binary as a new process to interpret the script.
Concept tested: Shebang (`#!`) interpreter mechanism
Source: https://www.man7.org/linux/man-pages/man7/exec.7.html
Topics
Community Discussion
No community discussion yet for this question.