From 911c3abdd83a1a3731b4a964fad3a9dc8aad26e5 Mon Sep 17 00:00:00 2001 From: gohai Date: Mon, 22 May 2017 19:36:37 +0200 Subject: [PATCH] Make shell pretend to be an interactive shell --- core/src/processing/core/PApplet.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index be0b95a3d..74488d480 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -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); }