environment set up fails if an existing environment variable contains `$.` and `'`
This is an example:
$ export something="foo $. bar ' 123 '"
$ . /cvmfs/lhcb.cern.ch/lib/LbEnv-stable.sh
********************************************************************************
* ---- LbEnv ---- *
********************************************************************************
--- User_release_area is set to /afs/cern.ch/user/m/marcocle/cmtuser
--- CMAKE_PREFIX_PATH is set to:
/cvmfs/lhcb.cern.ch/lib/lhcb
/cvmfs/lhcb.cern.ch/lib/lcg/releases
/cvmfs/lhcb.cern.ch/lib/lcg/app/releases
/cvmfs/lhcb.cern.ch/lib/lcg/external
/cvmfs/lhcb.cern.ch/lib/contrib
/cvmfs/lhcb.cern.ch/lib/var/lib/LbEnv/2639/stable/linux-64/lib/python3.9/site-packages/LbDevTools/data/cmake
--------------------------------------------------------------------------------
bash: export: `123': not a valid identifier
bash: export: `': not a valid identifier
The issue is that $.
is replaced by some environment normalization (in xenv
, I believe) so python -m LbEnv --sh
adds the problematic variable to the list of changes passed to eval
in https://gitlab.cern.ch/lhcb-core/LbEnvBootstrap/-/blob/master/data/LbEnv-flavour.sh#L23, which would not be a big problem if it wasn't for the '
not being properly escaped, resulting in the line
export something='foo bar ' 123 '' ;
passed to eval
, which is clearly incorrect.
The solution would be to
- avoid the substitution of
$.
as it is not needed in this case - properly escape
'
inLbEnv.Bootstrap
output (they should be replaced with'"'"'
)
Either change would be enough to avoid the issues seen in lhcb/Allen!1050 (comment 6302539), but both are needed for a correct behavior.