4 ms·
Using 'env bash' to find the local path is definitely the way to go. It also supports that occasional case where the user has installed modern bash somewhere in
by arglebargle123 7y ago
Using 'env bash' to find the local path is definitely the way to go. It also supports that occasional case where the user has installed modern bash somewhere in their local path (under their home directory) and finds that rather than the system copy.
#!/usr/bin/env bash
If you really want a predictable environment I usually go with something like this after the shebang, it supports bash and not-bash shells:
case "$(readlink /proc/$$/exe)" in */bash) set -euo pipefail ;; *) set -eu ;; esac
PATH=/usr/sbin:/usr/bin:/sbin:/bin
\unalias -a
I don't usually cd anywhere unless I need to.