From 2cedbefaef6edd0a3162c613ad4ee2ac60be28ed Mon Sep 17 00:00:00 2001 From: Sven Van Caekenberghe Date: Mon, 21 Oct 2024 13:10:13 +0200 Subject: [PATCH] Make PBPharoPipenvPathFinder class>>#macOSSearchPath a bit more robust [feenkcom/gtoolkit#3538] --- .../PBPharoPipenvPathFinder.class.st | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/PythonBridge-Pharo/PBPharoPipenvPathFinder.class.st b/src/PythonBridge-Pharo/PBPharoPipenvPathFinder.class.st index dada446..d6618f3 100644 --- a/src/PythonBridge-Pharo/PBPharoPipenvPathFinder.class.st +++ b/src/PythonBridge-Pharo/PBPharoPipenvPathFinder.class.st @@ -39,16 +39,14 @@ PBPharoPipenvPathFinder class >> extraPathNonWindows [ PBPharoPipenvPathFinder class >> macOSSearchPath [ "Try starting a login shell to pick up a wider PATH" - | shell envOutput env pathValue | + | shell envOutput pathValue | shell := Smalltalk os environment at: 'SHELL' ifAbsent: [ ^ #() ]. envOutput := (GtExternalProcessBuilder new command: shell; - args: #('-l' '-c' 'env'); + args: #('-l' '-c' 'env | grep -E ''^PATH='''); output) stdoutString. - env := (envOutput lines - collect: [ :line | ($= split: line) in: [ :parts | parts first -> parts second ] ]) - asDictionary. - pathValue := env at: #PATH ifAbsent: [ ^ #() ]. + envOutput isEmpty ifTrue: [ ^ #() ]. + pathValue := ($= split: envOutput lines first) second. ^ $: split: pathValue ]