my127 / workspace

Development environment tooling
MIT License
16 stars 13 forks source link

Avoid using addslashes in bash executor and pass in safely #149

Closed andytson-inviqa closed 1 year ago

andytson-inviqa commented 1 year ago

This means the following characters will be processed as literals rather than escaped in ways that don't work in some circumstances:

As literals, whether in $VARNAME '$VARNAME' "$VARNAME", they will be literals in there too (as in not processed as their scripting/shell varients).

The issue before was that when setting the variable VARNAME: "'test'" resulted in export VARNAME="\'test\'" from addslashes adding \ literals, making the literal value \'test\', which instead will no longer be the case, making the literal value 'test'.

It was fine before for " and \ since they needed escaping to be literals within "...".

A side-effect of this change is also that $ will be processed literal, whereas before it was possible to do:

command('...'):
  env:
    VAR: "$USER"
  exec:
    #!bash
    echo "$VAR" //  before: prints expansion of `$USER`, after: prints `$USER`

Note: