private static String[] getCurrentEnv(Ruby runtime) {
return getCurrentEnv(runtime, null);
}
private static String[] getCurrentEnv(Ruby runtime, Map mergeEnv) {
RubyHash hash = (RubyHash)runtime.getObject().fastGetConstant("ENV");
String[] ret;
if (mergeEnv != null && !mergeEnv.isEmpty()) {
ret = new String[hash.size() + mergeEnv.size()];
} else {
ret = new String[hash.size()];
}
int i=0;
for(Map.Entry e : (Set<Map.Entry>)hash.directEntrySet()) {
ret[i] = e.getKey().toString() + "=" + e.getValue().toString();
i++;
}
if (mergeEnv != null) for(Map.Entry e : (Set<Map.Entry>)mergeEnv.entrySet()) {
ret[i] = e.getKey().toString() + "=" + e.getValue().toString();