Skip to content

[BUG] Bad escaping for a string with \$ sequence #593

@Ph0enixKM

Description

@Ph0enixKM

Describe the bug
It's possible to mistakenly interpolate value into Amber string the following way: "\$variable". This shouldn't be allowed as it creates a lot of potential issues.

To Reproduce
This snippet will interpolate not only the variable name, but also the value that it contains:

amber -e 'let var = 42; echo "\${nameof var}"';

It happens because with interpolation we evaluate this amber code to this bash output:

var=42
echo "$var"

And then it returns 42

Expected behavior
The example written above should compile to:

var=42
echo "\$var"

And return $var as it should

Additional context
N/A

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcompiler

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions