Make shell pretend to be an interactive shell

This commit is contained in:
gohai
2017-05-22 19:36:37 +02:00
parent dd2efcc4d6
commit 911c3abdd8
+6 -1
View File
@@ -3554,14 +3554,19 @@ public class PApplet implements PConstants {
static public int shell(StringList stdout, StringList stderr, String... args) {
String shell;
String runCmd;
StringList argList = new StringList();
if (platform == WINDOWS) {
shell = System.getenv("COMSPEC");
runCmd = "/C";
} else {
shell = "/bin/sh";
runCmd = "-c";
// attempt emulate the behavior of an interactive shell
// can't use -i or -l since the version of bash shipped with macOS does not support this together with -c
// also we want to make sure no motd or similar gets returned as stdout
argList.append("if [ -f /etc/profile ]; then . /etc/profile >/dev/null 2>&1; fi;");
argList.append("if [ -f ~/.bash_profile ]; then . ~/.bash_profile >/dev/null 2>&1; elif [ -f ~/.bash_profile ]; then . ~/.bash_profile >/dev/null 2>&1; elif [ -f ~/.profile ]; then ~/.profile >/dev/null 2>&1; fi;");
}
StringList argList = new StringList();
for (String arg : args) {
argList.append(arg);
}