How do I get a bash script working on FreeBSD, OpenBSD and Linux without modifying it?
bash, freebsd, linux, openbsd
Solution
Using `env` in the shebang (`#!/usr/bin/env bash`) should make the script OS agnostic.
Problem
Sorry, the headline might be a bit irritating, but I didn't know anything better. Anyway, I want a bash script to work on FreeBSD, OpenBSD and Linux without modifying it, but bash isn't located at the same place in Linux and BSD. So, if I write `#!/bin/bash` then it won't work on BSD, because the bash shell is located in `/usr/local/bin/bash` there. Is there any solution to get this script working on both? Or do I really need to ship two scripts with different paths...?