We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d93b5f8 commit a122fd3Copy full SHA for a122fd3
+stdlib/get_shell.m
@@ -1,10 +1,22 @@
1
-%% GET_SHELL shell of the current user
2
-% return value of environment variable SHELL
3
-% this is mostly relevant on unix-like systems
+%% GET_SHELL full path to currently running shell
4
5
function s = get_shell()
6
7
-s = getenv("SHELL");
+if ispc()
+% https://stackoverflow.com/a/61469226
+ cmd = "(dir 2>&1 *`|echo CMD);&<# rem #>echo ($PSVersionTable).PSEdition";
8
+else
9
+% https://askubuntu.com/a/1349538
10
+ cmd = strcat("lsof -p ", '"$$"', " | grep -m 1 txt | xargs -n 1 | tail -n +9 | tr -d [:space:]");
11
+end
12
+
13
+[r, msg] = system(cmd);
14
15
+if r == 0
16
+ s = msg;
17
18
+ s = getenv("SHELL");
19
20
21
end
22
0 commit comments