summaryrefslogtreecommitdiffstats
path: root/src/VBox/Frontends/VBoxShell/vboxshell.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/Frontends/VBoxShell/vboxshell.py')
-rwxr-xr-xsrc/VBox/Frontends/VBoxShell/vboxshell.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/VBox/Frontends/VBoxShell/vboxshell.py b/src/VBox/Frontends/VBoxShell/vboxshell.py
index bd0222c7..f1083dd1 100755
--- a/src/VBox/Frontends/VBoxShell/vboxshell.py
+++ b/src/VBox/Frontends/VBoxShell/vboxshell.py
@@ -1,7 +1,28 @@
-#!/usr/bin/env python
+#!/bin/sh
# -*- coding: utf-8 -*-
# $Id: vboxshell.py $
+# The following checks for the right (i.e. most recent) Python binary available
+# and re-starts the script using that binary (like a shell wrapper).
+#
+# Using a shebang like "#!/bin/env python" on newer Fedora/Debian distros is banned [1]
+# and also won't work on other newer distros (Ubuntu >= 23.10), as those only ship
+# python3 without a python->python3 symlink anymore.
+#
+# Note: As Python 2 is EOL, we consider this last (and hope for the best).
+#
+# [1] https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/2PD5RNJRKPN2DVTNGJSBHR5RUSVZSDZI/
+''':'
+for python_bin in python3 python python2
+do
+ type "$python_bin" > /dev/null 2>&1 && exec "$python_bin" "$0" "$@"
+done
+echo >&2 "ERROR: Python not found! Please install this first in order to run this program."
+exit 1
+':'''
+
+from __future__ import print_function
+
"""
VirtualBox Python Shell.
@@ -19,8 +40,6 @@ Finally, shell allows arbitrary custom extensions, just create
P.S. Our apologies for the code quality.
"""
-from __future__ import print_function
-
__copyright__ = \
"""
Copyright (C) 2009-2023 Oracle and/or its affiliates.
@@ -43,7 +62,7 @@ along with this program; if not, see <https://www.gnu.org/licenses>.
SPDX-License-Identifier: GPL-3.0-only
"""
-__version__ = "$Revision: 155244 $"
+__version__ = "$Revision: 162975 $"
import gc