@@ -64,26 +64,32 @@ defmodule Expert.Port do
6464
6565 env = [ { "SHELL_SESSIONS_DISABLE" , "1" } ]
6666
67- case Path . basename ( shell ) do
68- # Ideally, it should contain the path to shell (e.g. `/usr/bin/fish`),
69- # but it might contain only the name of the shell (e.g. `fish`).
70- "fish" ->
71- # Fish uses space-separated PATH, so we use the built-in `string join` command
72- # to join the entries with colons and have a standard colon-separated PATH output
73- # as in bash, which is expected by `:os.find_executable/2`.
74- { path , 0 } =
75- System . cmd ( shell , [ "-i" , "-l" , "-c" , "cd #{ directory } && string join ':' $PATH" ] ,
76- env: env
77- )
78-
79- path
80-
81- _ ->
82- { path , 0 } =
83- System . cmd ( shell , [ "-i" , "-l" , "-c" , "cd #{ directory } && echo $PATH" ] , env: env )
84-
85- path
86- end
67+ path =
68+ case Path . basename ( shell ) do
69+ # Ideally, it should contain the path to shell (e.g. `/usr/bin/fish`),
70+ # but it might contain only the name of the shell (e.g. `fish`).
71+ "fish" ->
72+ # Fish uses space-separated PATH, so we use the built-in `string join` command
73+ # to join the entries with colons and have a standard colon-separated PATH output
74+ # as in bash, which is expected by `:os.find_executable/2`.
75+ { path , 0 } =
76+ System . cmd ( shell , [ "-i" , "-l" , "-c" , "cd #{ directory } && string join ':' $PATH" ] ,
77+ env: env
78+ )
79+
80+ path
81+
82+ _ ->
83+ { path , 0 } =
84+ System . cmd ( shell , [ "-i" , "-l" , "-c" , "cd #{ directory } && echo $PATH" ] , env: env )
85+
86+ path
87+ end
88+
89+ path
90+ |> String . trim ( )
91+ |> String . split ( "\n " )
92+ |> List . last ( )
8793 end
8894
8995 @ doc """
0 commit comments