Closed benwalch closed 1 year ago
good catch! I think we have been messing with the temporary variables anyway, so I think it didn't hurt so far - just until you have spotted that the result is not the expected one in this particular case. I'd go with the proposed fix. Thanks for this contribution.
parse_yaml produces wrong results if a variable
i
is set to a value in current bash session.Reproduce:
i
:$ i="ZZZ test string ZZZ"
echo $(parse_yaml path/to/valid/yaml.yaml)
The output contains strings with of the initial contents of the variable
$i
of the current bash session.An approach for solving this issue could be inside the parse_yaml function to back up the current value of
$i
in a temporary variable, clear the$i
variable, run the function, and then write back the backup to the variable. Or, just don't care about the contents of$i
(since its use case is 99% a temporary loop variable) and clear it at the beginning of the function.