5 ms·
It should be pushd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 not cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 with a matching popd at the end O
by z29LiTp5qUC30n 6y ago
It should be pushd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1
not cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1
with a matching popd at the end
Otherwise it can screw up parent scripts
- Galanwe 6y agoNot unless the script is source'd, which is very unlikely.
- dastx 6y agoReally scripts should avoid called `cd` or `pushd`/`popd` wherever possible. It's a lot better to just work with absolute directories, i.e. as someone else pointed out: DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
- Brian_K_White 6y agono no no... god this is gross and awful SELF=${0##*/} # aka basename DIR=${0%/*} # aka dirname