<commit_before>import {delimiter} from "path";
import {executeCommandWithShellConfig} from "../PTY";
import {clone} from "lodash";
import {homeDirectory} from "../utils/Common";
import * as Path from "path";
import {AbstractOrderedSet} from "../utils/OrderedSet";

const ignoredEnvironmentVariables = [
    "NODE_ENV",
];
export const processEnvironment: Dictionary<string> = {};
export async function loadEnvironment(): Promise<void> {
    const lines = await executeCommandWithShellConfig("env");

    lines.forEach(line => {
        let [key, value] = line.trim().split("=");

        if (!ignoredEnvironmentVariables.includes(key)) {
            processEnvironment[key] = value;
        }<commit_msg>Strip bash funcs (#640)<commit_after>import {delimiter} from "path";
import {executeCommandWithShellConfig} from "../PTY";
import {clone} from "lodash";
import {homeDirectory} from "../utils/Common";
import * as Path from "path";
import {AbstractOrderedSet} from "../utils/OrderedSet";

const ignoredEnvironmentVariables = [
    "NODE_ENV",
];

const isIgnoredEnvironmentVariable = (varName: string) => {
    if (ignoredEnvironmentVariables.includes(varName)) {
        return true;
    } else if (/^BASH_FUNC\w+%%$/.test(varName)) {
        return true;
    } else {
        return false;
    }
};

export const processEnvironment: Dictionary<string> = {};
export async function loadEnvironment(): Promise<void> {
    const lines = await executeCommandWithShellConfig("env");

    lines.forEach(line => {
        let [key, value] = line.trim().split("=");

        // Strip bash functions from environment, as they cause issues.
        // TODO: actually support bash functions
        if (!isIgnoredEnvironmentVariable(key)) {
            processEnvironment[key] = value;
        }
{'fraction_non_alphanumeric': 0.1371012870733072, 'fraction_numerical': 0.0016787912702853946, 'mean_word_length': 3.8194070080862534, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '482655', 'n_tokens_mistral': 496, 'n_tokens_neox': 480, 'n_words': 133}