Last active
September 3, 2025 17:30
-
-
Save jpickwell/3246190f4538bf67d8319f3c90615976 to your computer and use it in GitHub Desktop.
Bash __dirname
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # shellcheck disable=SC2311 | |
| __dirname="$(_dn(){ local s="$1" d; while [[ -h "${s}" ]]; do d="$(cd -P -- "$(dirname -- "${s}")" 1>/dev/null 2>&1 && pwd -P)"; s="$(readlink "${s}")"; [[ "${s}" == /* ]] || s="${d}/${s}"; done; cd -P -- "$(dirname -- "${s}")" 1>/dev/null 2>&1 && pwd -P; }; _dn "${BASH_SOURCE[0]}")" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment