mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-20 05:36:23 +02:00
init.sh: Use readlink in pybin()
Use realpath only as a fallback. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+1
-2
@@ -80,8 +80,7 @@ pybin()
|
|||||||
# ideally, don't rely on PATH or hardcoded paths if python venv.
|
# ideally, don't rely on PATH or hardcoded paths if python venv.
|
||||||
# use the *real*, direct executable linked to by the venv symlink
|
# use the *real*, direct executable linked to by the venv symlink
|
||||||
if [ $venv -gt 0 ] && [ -L "`command -v "$1" 2>/dev/null`" ]; then
|
if [ $venv -gt 0 ] && [ -L "`command -v "$1" 2>/dev/null`" ]; then
|
||||||
# realpath isn't posix, but available mostly universally
|
pypath="$(findpath \
|
||||||
pypath="$(realpath \
|
|
||||||
"$(command -v "$1" 2>/dev/null)" 2>/dev/null || :)"
|
"$(command -v "$1" 2>/dev/null)" 2>/dev/null || :)"
|
||||||
[ -e "$pypath" ] && [ ! -d "$pypath" ] && \
|
[ -e "$pypath" ] && [ ! -d "$pypath" ] && \
|
||||||
[ -x "$pypath" ] && printf "%s\n" "$pypath" && return 0; :
|
[ -x "$pypath" ] && printf "%s\n" "$pypath" && return 0; :
|
||||||
|
|||||||
@@ -144,6 +144,18 @@ singletree()
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
findpath()
|
||||||
|
{
|
||||||
|
[ $# -gt 0 ] || err "findpath: No arguments provided"
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
found="`readlink -f "$1" 2>/dev/null`" || return 1; :
|
||||||
|
[ -n "$found" ] || found="`realpath "$1" 2>/dev/null`" || \
|
||||||
|
return 1; :
|
||||||
|
printf "%s\n" "$found"
|
||||||
|
shift 1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
fx_()
|
fx_()
|
||||||
{
|
{
|
||||||
fd="`mktemp`" && x_ rm -f "$fd" && x_ touch "$fd"
|
fd="`mktemp`" && x_ rm -f "$fd" && x_ touch "$fd"
|
||||||
|
|||||||
Reference in New Issue
Block a user