mirror of
https://github.com/sigmasternchen/sh.js
synced 2025-03-14 23:18:54 +00:00
fixed variable expansion in single-quotes
This commit is contained in:
parent
97b4860961
commit
741ff1c347
1 changed files with 8 additions and 4 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue