I mean if I just use bash to run the file like bash ./myscript.sh will it be enough or there are some pitfalls?
Asked
Active
Viewed 218 times
0
through.a.haze
- 101
- 2
-
If you call it like that, you don't need to make it executable. – Stefan Hamcke Apr 16 '19 at 08:42
-
@StefanHamcke so there is no difference between making it executable and run by `./myscript.sh` or run it explicitly by calling `bash ./myscript.sh`, right? – through.a.haze Apr 16 '19 at 08:45
-
This depends on the shebang. – pLumo Apr 16 '19 at 08:49
-
@RoVo the shebang is `#!/bin/bash` – through.a.haze Apr 16 '19 at 08:51
-
And what does `type bash` say. If it's the same, there will be no difference. Or if you run `/bin/bash myscript.sh`. – pLumo Apr 16 '19 at 08:52
-
If that's your shebang, then your current shell will always start a subshell `bash` which executes the commands in your script, provided the command `bash` in your shell starts `/bin/bash`. – Stefan Hamcke Apr 16 '19 at 08:52
-
@RoVo it says the same. Thanks RoVo and Stefan Hamcke! – through.a.haze Apr 16 '19 at 09:00
-
or maybe better [What is the difference between ./ and sh to run a script?](https://askubuntu.com/questions/22910/what-is-the-difference-between-and-sh-to-run-a-script). – pLumo Apr 16 '19 at 09:10