From f8c215775a72e7a49d92ecd9b8cc2ac0e3851242 Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Tue, 15 Jun 2021 12:35:44 +0200 Subject: [PATCH] better zsh and fish version detection --- src/common/detectTerminalShell.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/common/detectTerminalShell.c b/src/common/detectTerminalShell.c index b019ddc01..a0c0dabab 100644 --- a/src/common/detectTerminalShell.c +++ b/src/common/detectTerminalShell.c @@ -156,26 +156,24 @@ static void getShellVersionBash(FFstrbuf* exe, FFstrbuf* version) static void getShellVersionZsh(FFstrbuf* exe, FFstrbuf* version) { ffProcessAppendStdOut(version, (char* const[]) { - "env", - "-i", exe->chars, - "--no-rcs", - "-c", - "printf \"%s\" \"$ZSH_VERSION\"", + "--version", NULL }); + ffStrbufTrimRight(version, '\n'); + ffStrbufSubstrBeforeLastC(version, ' '); + ffStrbufSubstrAfterFirstC(version, ' '); } static void getShellVersionFish(FFstrbuf* exe, FFstrbuf* version) { ffProcessAppendStdOut(version, (char* const[]) { - "env", - "-i", exe->chars, - "-c", - "printf \"%s\" \"$FISH_VERSION\"", + "--version", NULL }); + ffStrbufTrimRight(version, '\n'); + ffStrbufSubstrAfterLastC(version, ' '); } static void getShellVersionGeneric(FFstrbuf* exe, const char* exeName, FFstrbuf* version)