From 259e3076fabc2409f66d5fd1a4c365e43d9cfbc8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 7 Mar 2022 18:36:56 +0530 Subject: [PATCH] Ensure python is searched for only once --- shell-integration/ssh/bootstrap.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/shell-integration/ssh/bootstrap.sh b/shell-integration/ssh/bootstrap.sh index fab5c9200..9a6fcc1a2 100644 --- a/shell-integration/ssh/bootstrap.sh +++ b/shell-integration/ssh/bootstrap.sh @@ -10,7 +10,14 @@ cleanup_on_bootstrap_exit() { die() { printf "\033[31m%s\033[m\n\r" "$*" > /dev/stderr; cleanup_on_bootstrap_exit; exit 1; } +python_detected="0" + detect_python() { + if [ python_detected = "1" ]; then + [ -n "$python" ] && return 0; + return 1; + fi + python_detected="1" python=$(command -v python3) if [ -z "$python" ]; then python=$(command -v python2); fi if [ -z "$python" ]; then python=$(command -v python); fi