4 ms·
You don't need realpath. The `cd` into the directory + `pwd` is equivalent. BASH_SOURCE[0] obviously only works with bash.
by js2 3y ago
You don't need realpath. The `cd` into the directory + `pwd` is equivalent.
BASH_SOURCE[0] obviously only works with bash.
- account42 3y ago> You don't need realpath Yes you do (or a suitable alternative, e.g. GNU readlink). > The `cd` into the directory + `pwd` is equivalent. You won't know which directory to cd to without realpath. Just stripping off the filename does not get you the correct directory if the file itself is a symlink, which is a common use case.
- js2 3y agoDoh, you're right. Thank you for the correction.