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"
This commit is contained in:
parent
c3d0f421e1
commit
393e44c4cc
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue