Correction de bug #3
This commit is contained in:
parent
06cd424919
commit
116a661e42
@ -151,13 +151,18 @@ public class BakefileParser {
|
||||
|
||||
while (matcher.find()) {
|
||||
String varName = matcher.group(1) != null ? matcher.group(1) : matcher.group(2);
|
||||
if (!processedVars.contains(varName) && variables.containsKey(varName)) {
|
||||
String replacement = variables.get(varName);
|
||||
// Modification ici: remplacer par la valeur de la variable ou par une chaîne vide si elle n'existe pas
|
||||
String replacement = "";
|
||||
if (variables.containsKey(varName)) {
|
||||
replacement = variables.get(varName);
|
||||
} else if (BakeCLI.isDebug()) {
|
||||
System.out.println("Debug: Variable '" + varName + "' not defined, replacing with empty string");
|
||||
}
|
||||
|
||||
matcher.appendReplacement(sb, Matcher.quoteReplacement(replacement));
|
||||
changed = true;
|
||||
processedVars.add(varName);
|
||||
}
|
||||
}
|
||||
matcher.appendTail(sb);
|
||||
result = sb.toString();
|
||||
|
||||
@ -328,10 +333,24 @@ public class BakefileParser {
|
||||
// Ajuster i pour sauter les lignes traitées (moins 1 car la boucle for incrémente i)
|
||||
i += linesUsed - 1;
|
||||
} else {
|
||||
commands.add(command);
|
||||
// Pour les commandes simples, créer une liste avec une seule ligne
|
||||
String executableCommand = command;
|
||||
commands.add(executableCommand);
|
||||
// Pour l'affichage, préserver le formatage mais remplacer les variables
|
||||
String displayLine = line;
|
||||
// Ne pas modifier les lignes qui commencent par @ (silencieuses)
|
||||
if (command.startsWith("@")) {
|
||||
displayLine = line; // Garder le formatage complet pour les commandes silencieuses
|
||||
} else {
|
||||
// Remplacer les variables dans la partie de la commande uniquement (après la tabulation)
|
||||
Matcher cmdMatcher = COMMAND_PATTERN.matcher(line);
|
||||
if (cmdMatcher.matches()) {
|
||||
String cmdPart = cmdMatcher.group(1);
|
||||
String cmdWithVars = replaceVariables(cmdPart);
|
||||
displayLine = "\t" + cmdWithVars;
|
||||
}
|
||||
}
|
||||
List<String> singleLineDisplay = new ArrayList<>();
|
||||
singleLineDisplay.add(line);
|
||||
singleLineDisplay.add(displayLine);
|
||||
displayCommands.add(singleLineDisplay);
|
||||
}
|
||||
continue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user