@Internal("Sys.setenv") public static LogicalVector setEnvironment( @Current Context context, StringVector names, StringVector values) { Map<String, String> map = context.getSession().getSystemEnvironment(); LogicalArrayVector.Builder result = new LogicalArrayVector.Builder(); for (int i = 0; i != names.length(); ++i) { map.put(names.getElementAsString(i), values.getElementAsString(i)); result.add(true); } return result.build(); }
@Internal("Sys.getenv") public static StringVector getEnvironment( @Current Context context, StringVector names, String unset) { StringVector.Builder result = new StringArrayVector.Builder(); Map<String, String> map = context.getSession().getSystemEnvironment(); if (names.length() == 0) { for (Map.Entry<String, String> entry : map.entrySet()) { result.add(entry.getKey() + "=" + entry.getValue()); } } else { for (String name : names) { String value = map.get(name); result.add(value == null ? unset : value); } } return result.build(); }