fixed variable expansion in single-quotes

This commit is contained in:
overflowerror 2022-04-08 20:28:16 +02:00
parent 97b4860961
commit 741ff1c347

View file

@ -283,7 +283,7 @@
if (buffer[0] == '$') {
value.add(astValueVar(buffer.substring(1)));
} else {
value.add(astValueString(buffer));
value.add(astValueString(buffer.replaceAll('\\$', '$')));
}
buffer = "";
}
@ -293,7 +293,7 @@
if (buffer[0] == '$') {
current.add(astValueVar(buffer.substring(1)));
} else {
current.add(astValueString(buffer));
current.add(astValueString(buffer.replaceAll('\\$', '$')));
}
buffer = "";
}
@ -306,7 +306,7 @@
if (buffer[0] == '$') {
value.add(astValueVar(buffer.substring(1)));
} else {
value.add(astValueString(buffer));
value.add(astValueString(buffer.replaceAll('\\$', '$')));
}
buffer = "";
}
@ -316,7 +316,7 @@
if (buffer[0] == '$') {
current.add(astValueVar(buffer.substring(1)));
} else {
current.add(astValueString(buffer));
current.add(astValueString(buffer.replaceAll('\\$', '$')));
}
buffer = "";
}
@ -339,6 +339,10 @@
} else if (c == "'") {
const end = findSymbolInScope(content, line, "'", i + 1, length);
buffer += content.substring(i + 1, end);
if (buffer && buffer[0] == '$') {
// mask dollar sign in buffer so the variable is not expanded
buffer = '\\' + buffer;
}
i = end;
} else if (c == '=' && current.size() == 0) {
current = astAssignment(buffer);