// Unix environment variables are can be the character set `[a-zA-Z0-9_]` so we
// need to replace anything that isn't in that to the underscore character. If
// the variable name starts with a number then prefix it with an underscore.

function shellEscape(name) {
    name = name.replace(/[^a-zA-Z0-9_]/g , '_');

    if (name.match(/^[0-9]/)) {
        name = '_' + name;
    }

    return name;
}

// Convert a string to a unix environment variable name by:
// * Trimming excess space from the provided string and optional stub
// * Prefixing the string with an optional stub, followed by an underscore
// * Replacing invalid characters with an underscore
// * Converting the resultant string to uppercase

function toVariableName(string, stub) {

    var name = '';

    if (stub !== undefined) {
        name = stub.trim();
    }

    if (!name) {
        name = string.trim();
    } else {
        name += '_' + string.trim();
    }

    return shellEscape(name).toUpperCase();
}

module.exports.toVariableName = toVariableName;


@@ -981,16 +981,529 @@
 e();%0A%7D%0A%0A
+// %60getOverride%60 checks the for an environment variable with the given %60name%60%0A// returning its value if it's set. Numeric values are automatically converted.%0A// If no value is found then the given default value will be returned.%0A%0Afunction getOverride(name, defaultValue) %7B%0A    var value = process.env%5Bname%5D;%0A    var result = defaultValue;%0A%0A    if (value !== undefined) %7B%0A        if (isNaN(+value)) %7B%0A            result = value;%0A        %7D else %7B%0A            result = +value;%0A        %7D%0A    %7D%0A%0A    return result;%0A%7D%0A%0A
 module.e
@@ -1541,10 +1541,52 @@
 bleName;
+%0Amodule.exports.getOverride = getOverride;
 %0A%0A

Add method to environment.js to allow retrieval of overrides