From 78bf552a97ac656a445fb7e055e423bd4dfc73d4 Mon Sep 17 00:00:00 2001 From: Ninja Inc Date: Mon, 13 May 2024 20:31:42 +0200 Subject: [PATCH] Workaround for #238 regression / #245 issue (#247) --- RELEASE.md | 3 +++ virtualfish/loader/cli.py | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 RELEASE.md diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000..a7b151a --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,3 @@ +Release type: patch + +Restore support for older versions of Fish. diff --git a/virtualfish/loader/cli.py b/virtualfish/loader/cli.py index 5582c04..6b89704 100644 --- a/virtualfish/loader/cli.py +++ b/virtualfish/loader/cli.py @@ -25,13 +25,15 @@ def check_fish_version(): """Display a warning if the minimum Fish version is not installed. Bail silently if the 'packaging' module is missing or if Fish is not installed.""" try: + import re import subprocess from packaging import version - cmd = ["fish", "-N", "-c", "echo $version"] - fish_version = subprocess.check_output(cmd).decode("utf-8").strip() - # Remove any extraneous hyphen-suffixed bits - fish_version = fish_version.partition("-")[0] + cmd = ["fish", "--version"] + fish_output = subprocess.check_output(cmd).decode("utf-8") + # Remove any extraneous prefix and hyphen-suffixed bits + fish_matches = re.match(r".*version ([\d\.]+)", fish_output) + fish_version = fish_matches.group(1) if version.parse(fish_version) < version.parse(minimum_fish_version): log.warning( """{}WARNING: VirtualFish requires Fish {} or higher.