mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Remove use of command -v from linux-installer.sh
This commit is contained in:
parent
64c375848b
commit
f04b5eea20
@ -2,20 +2,47 @@
|
|||||||
# linux-installer.sh
|
# linux-installer.sh
|
||||||
# Copyright (C) 2018 Kovid Goyal <kovid at kovidgoyal.net>
|
# Copyright (C) 2018 Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
PYTHON3=$(command -v python3)
|
search_for_python() {
|
||||||
PYTHON2=$(command -v python2)
|
# We have to search for python as Ubuntu, in its infinite wisdom decided
|
||||||
|
# to release 18.04 with no python symlink, making it impossible to run polyglot
|
||||||
|
# python scripts.
|
||||||
|
|
||||||
if [ -x "$PYTHON3" ]
|
# We cannot use command -v as it is not implemented in the posh shell shipped with
|
||||||
then
|
# Ubuntu/Debian. Similarly, there is no guarantee that which is installed.
|
||||||
PYTHON=python3
|
# Shell scripting is a horrible joke, thank heavens for python.
|
||||||
else
|
local IFS=:
|
||||||
if [ -x "$PYTHON2" ]
|
if [ $ZSH_VERSION ]; then
|
||||||
then
|
# zsh does not split by default
|
||||||
PYTHON=python2;
|
setopt sh_word_split
|
||||||
else
|
|
||||||
PYTHON=python;
|
|
||||||
fi
|
fi
|
||||||
fi
|
local candidate_path
|
||||||
|
local candidate_python
|
||||||
|
local pythons=python3:python2
|
||||||
|
# disable pathname expansion (globbing)
|
||||||
|
set -f
|
||||||
|
for candidate_path in $PATH
|
||||||
|
do
|
||||||
|
if [ ! -z $candidate_path ]
|
||||||
|
then
|
||||||
|
for candidate_python in $pythons
|
||||||
|
do
|
||||||
|
if [ ! -z "$candidate_path" ]
|
||||||
|
then
|
||||||
|
if [ -x "$candidate_path/$candidate_python" ]
|
||||||
|
then
|
||||||
|
printf "$candidate_path/$candidate_python"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
set +f
|
||||||
|
printf "python"
|
||||||
|
}
|
||||||
|
|
||||||
|
PYTHON=$(search_for_python)
|
||||||
|
echo Using python executable: $PYTHON
|
||||||
|
|
||||||
$PYTHON -c "import sys; script_launch=lambda:sys.exit('Download of installer failed!'); exec(sys.stdin.read()); script_launch()" "$@" <<'CALIBRE_LINUX_INSTALLER_HEREDOC'
|
$PYTHON -c "import sys; script_launch=lambda:sys.exit('Download of installer failed!'); exec(sys.stdin.read()); script_launch()" "$@" <<'CALIBRE_LINUX_INSTALLER_HEREDOC'
|
||||||
# {{{
|
# {{{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user