Resolve symlinks to find __origin

This commit is contained in:
Martin Winkler 2022-03-16 18:00:40 +01:00
parent 49eed4f283
commit a0e38e3d8e
3 changed files with 4 additions and 0 deletions

View File

@ -14,6 +14,7 @@ Released: TBA.
[Diff](https://github.com/kvz/bash3boilerplate/compare/v2.4.2...master).
- [x] Add feature to edit/update comments in ini file (#132, @rfuehrer)
- [x] New magic variable `__origin` when called via symlink (@efelon)
## v2.4.2

View File

@ -166,6 +166,7 @@ We are looking for endorsements! Are you also using b3bp? [Let us know](https://
- [Lukas Stockner](mailto:oss@genesiscloud.com)
- [Gert Goet](https://github.com/eval)
- [@rfuehrer](https://github.com/rfuehrer)
- [@efelon](https://github.com/efelon)
## License

View File

@ -47,6 +47,7 @@ fi
__dir="$(cd "$(dirname "${BASH_SOURCE[${__b3bp_tmp_source_idx:-0}]}")" && pwd)"
__file="${__dir}/$(basename "${BASH_SOURCE[${__b3bp_tmp_source_idx:-0}]}")"
__base="$(basename "${__file}" .sh)"
__origin="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[${__b3bp_tmp_source_idx:-0}]}")")" && pwd)"
# shellcheck disable=SC2034,SC2015
__invocation="$(printf %q "${__file}")$( (($#)) && printf ' %q' "$@" || true)"
@ -412,6 +413,7 @@ info "__i_am_main_script: ${__i_am_main_script}"
info "__file: ${__file}"
info "__dir: ${__dir}"
info "__base: ${__base}"
info "__origin: ${__origin}"
info "OSTYPE: ${OSTYPE}"
info "arg_f: ${arg_f}"