@@ -3,7 +3,7 @@ package editor
3
3
import (
4
4
"context"
5
5
"fmt"
6
- "io/ioutil "
6
+ "io"
7
7
"log"
8
8
"os"
9
9
"os/exec"
@@ -867,31 +867,34 @@ func (e *Editor) setEnvironmentVariables() {
867
867
}
868
868
869
869
// If the OS is MacOS and the application is launched from an .app
870
- if runtime .GOOS == "darwin" && e . ppid == 1 {
870
+ if runtime .GOOS == "darwin" && os . Getenv ( "TERM" ) == "" {
871
871
shell := os .Getenv ("SHELL" )
872
872
if shell == "" {
873
- shell = os . Getenv ( "/bin/bash" )
873
+ shell = "/bin/zsh" // fallback
874
874
}
875
- cmd := exec . Command ( shell , "-l" , "-c" , "env" , "-i" )
876
- // cmd := exec.Command("printenv ")
875
+
876
+ cmd := exec .Command (shell , "-l" , "-c" , "env " )
877
877
stdout , err := cmd .StdoutPipe ()
878
878
if err != nil {
879
879
e .putLog (err )
880
880
return
881
881
}
882
+
882
883
if err := cmd .Start (); err != nil {
883
884
e .putLog (err )
884
885
return
885
886
}
886
- output , err := ioutil .ReadAll (stdout )
887
+
888
+ output , err := io .ReadAll (stdout )
889
+ stdout .Close ()
887
890
if err != nil {
888
891
e .putLog (err )
889
- stdout .Close ()
890
892
return
891
893
}
892
- for _ , b := range strings .Split (string (output ), "\n " ) {
893
- splits := strings .SplitN (b , "=" , 2 )
894
- if len (splits ) > 1 {
894
+
895
+ for _ , line := range strings .Split (string (output ), "\n " ) {
896
+ splits := strings .SplitN (line , "=" , 2 )
897
+ if len (splits ) == 2 {
895
898
_ = os .Setenv (splits [0 ], splits [1 ])
896
899
}
897
900
}
0 commit comments