bat icon indicating copy to clipboard operation
bat copied to clipboard

Allow bat to replace variables on text

Open patrickelectric opened this issue 10 months ago • 2 comments

Something like this:

This is your home: ${HOME}

should be replaced automatically by the env variable HOME

patrickelectric avatar Mar 25 '24 18:03 patrickelectric

I personally feel like having this happen automatically would not be desired at all, as it could be highly confusing. Especially when looking at a config file for something which would actually be deployed to a different environment. Perhaps some wrapper script to pre-process it would suffice?

keith-hall avatar Mar 25 '24 20:03 keith-hall

I'm with @keith-hall on this. Automatically expanding environment variables will likely cause confusion, even in code.

function newTempFile($tmpdir) {
    $file = fopen("${tmpdir}/file.txt", "w");
    if ($file === false) {
        // do something
    }

    return $file;
}

If environment variables were replaced, it would lead the user into thinking the new temporary file is located at /tmp instead of the directory specified as the function parameter.

A preprocessing step would be a better place to do environment variable expansion.

eth-p avatar Mar 26 '24 17:03 eth-p