I wrote a cute script, it start with #!/bin/bash. The shell I use is bash, but the script only works if I change the she-bang for #!/bin/sh.
May someone explain to me why? Is that because the root shell is still sh?
1. missing lead "/" (I guess this is a typo)
2. wrong path. shells/bash is third-party software so it's in /usr/local/bin/bash not /bin/bash. This is FreeBSD, not Linux.
Just keep in mind that it's a bit different than Linux. The reason #!/bin/sh would work is because that is a shell on FreeBSD. You can type sh at a command prompt and you can use it and see what it does. It's missing some things that bash has but it is the default shell for a user--that is a non root new user.
For example, it does't have history, nor $UID
As has been typed, to use bash in a script you would use, on FreeBSD, #!/usr/local/bin/bash
You *could* depending upon circumstances, make your script more portable by using
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.