Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • So I guess the best thing to do is to test all script in the checkbashism tool. I heard that some distro, like Debian and Ubuntu (need confirmation for this one) had their bin/sh now symlink to dash. Does dash is compatible with the bourn shell? If yes, then at least all Debian and Ubuntu shell script should be fine under FreeBSD. Commented Aug 6, 2012 at 2:39
  • @user1115057 only shell scripts with /bin/sh as shebang. A shell script still can explicitly use /bin/bash. Anyway most shell scripts probably will run fine under /bin/sh but the problem will be the user tools, e.g. most shell script expect GNU userland which will probably be more of a problem than just some syntax error. I also added a link to the bash reference which lists the different behavior in posix mode Commented Aug 6, 2012 at 2:43
  • Ok from what I read, BSD use ash as their bin/sh, while Debian & Ubuntu use dash. If those shell are compatible, it mean I wont have anymore issue with shebang #!/bin/sh. But as you said, there will be other issue related to the userland... Commented Aug 6, 2012 at 3:33
  • 1
    I came across today and found this very perplexing. If /bin/sh is a symlink to /bin/bash, HOW does /bin/bash know it was called with /bin/sh?? As an example, if I run ln -s /usr/bin/bash ./foo and run ./foo it will be regular bash. If I ln -s /usr/bin/bash ./sh and run ./sh it will run in POSIX mode. How does bash know how it was called?? Commented Sep 20, 2019 at 21:02
  • 2
    @MaxCoplan Through the zeroth argument (argv[0] in C). Commented Oct 19, 2023 at 8:39