What does the line '!/bin/sh -e' do?
That line defines what program will execute the given script.
For sh
normally that line should start with the # character as so:
#!/bin/sh -e
The -e flag's long name is errexit
, causing the script to immediately exit on the first error. A more detailed description from man sh
:
If not interactive, exit immediately if any untested command fails. The exit status of a command is considered to be explicitly tested if the command is used to control an
if
,elif
,while
, oruntil
; or if the command is the left hand operand of an&&
or||
operator.
#!/bin/bash
this is the first line in the script to tell the system to use bash shell to execute the script.