envkernel.sh: use realpath to deal with symlink
Suggest to change suffix to bash: POSIX does not provide a way to detect sourced script path, and the working method in this script is bash-specific. (The sh-method would not working in some cases like shell in shell) Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org> Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230618045230.28622-1-11857526-nexplorer-3e@users.noreply.gitlab.com%3E
This commit is contained in:
parent
185973fd97
commit
620f3af691
|
@ -49,7 +49,7 @@ export_pmbootstrap_dir() {
|
||||||
# See also: <https://stackoverflow.com/a/29835459>
|
# See also: <https://stackoverflow.com/a/29835459>
|
||||||
# shellcheck disable=SC3054
|
# shellcheck disable=SC3054
|
||||||
if [ -n "${BASH_SOURCE[0]}" ]; then
|
if [ -n "${BASH_SOURCE[0]}" ]; then
|
||||||
script_dir="$(dirname "${BASH_SOURCE[0]}")"
|
script_dir="$(dirname "$(realpath "$BASH_SOURCE")")"
|
||||||
else
|
else
|
||||||
script_dir="$(dirname "$1")"
|
script_dir="$(dirname "$1")"
|
||||||
fi
|
fi
|
||||||
|
@ -324,9 +324,7 @@ check_and_deactivate() {
|
||||||
print_usage() {
|
print_usage() {
|
||||||
# shellcheck disable=SC3054
|
# shellcheck disable=SC3054
|
||||||
if [ -n "${BASH_SOURCE[0]}" ]; then
|
if [ -n "${BASH_SOURCE[0]}" ]; then
|
||||||
echo "usage: source $(basename "${BASH_SOURCE[0]}")"
|
echo "usage: source $(basename "$(realpath "$BASH_SOURCE")")"
|
||||||
else
|
|
||||||
echo "usage: source $(basename "$1")"
|
|
||||||
fi
|
fi
|
||||||
echo "optional arguments:"
|
echo "optional arguments:"
|
||||||
echo " --fish Print fish alias syntax (internally used)"
|
echo " --fish Print fish alias syntax (internally used)"
|
||||||
|
|
Loading…
Reference in New Issue