Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"standard" shebang with `-e`

Tags:

bash

unix

So I used to start my bash scripts with #!/bin/bash -e (call bash, and exit on first error)

Now i'm moving to the more portable form #!/usr/bin/env bash But setting -e doesn't work

#!/usr/bin/env bash -e
echo 'hi'

# output:
>> /usr/bin/env: ‘bash -e’: No such file or directory

How can I use -e with the portable shebang?

like image 726
mjalajel Avatar asked Oct 17 '25 14:10

mjalajel


1 Answers

use:

#!/usr/bin/env -S bash -e

From the env manpage:

-S, --split-string=S
       process and split S into separate arguments; used to pass
       multiple arguments on shebang lines
like image 57
Vinny Avatar answered Oct 20 '25 04:10

Vinny



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!