Compare commits

...

1 Commits

Author SHA1 Message Date
Oliver Smith 393e44c4cc
envkernel.sh: support sourcing from symlink (!1766)
Use readlink -f to resolve all symlinks in the envkernel.sh path.

Example:
$ ln -s ~/code/pmbootstrap/helpers/envkernel.sh ~/.local/bin
$ cd ~/code/linux
$ source ~/.local/bin/envkernel.sh

Please note that "source envkernel.sh" will only work with bash, as we
can use its ${BASH_SOURCE[0]} variable. For other shells, I would
recommend to set up an alias instead, e.g. for .zshrc:

alias envkernel="source ~/code/pmbootstrap/helpers/envkernel.sh"
2019-03-09 21:36:34 +01:00
1 changed files with 2 additions and 2 deletions

View File

@ -42,9 +42,9 @@ export_pmbootstrap_dir() {
# See also: <https://stackoverflow.com/a/29835459>
# shellcheck disable=SC2039
if [ -n "${BASH_SOURCE[0]}" ]; then
script_dir="$(dirname "${BASH_SOURCE[0]}")"
script_dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
else
script_dir="$(dirname "$1")"
script_dir="$(dirname "$(readlink -f "$1")")"
fi
# Fail with debug information