From d8477dd7d3ac4e960aeae1a0baaadf0b3c32bfb6 Mon Sep 17 00:00:00 2001 From: Yanis HAMOUDI <yanis.hamoudi@etu.u-pec.fr> Date: Sat, 15 Mar 2025 18:06:47 +0100 Subject: [PATCH] Correction de bug #4 --- .../monlouyan/bakefile/CommandExecutor.java | 61 ++++++++++++++----- 1 file changed, 45 insertions(+), 16 deletions(-) diff --git a/src/fr/monlouyan/bakefile/CommandExecutor.java b/src/fr/monlouyan/bakefile/CommandExecutor.java index 8fe286c..87ff678 100644 --- a/src/fr/monlouyan/bakefile/CommandExecutor.java +++ b/src/fr/monlouyan/bakefile/CommandExecutor.java @@ -90,27 +90,56 @@ public class CommandExecutor { } if (isCircular){ - if (!silent && displayLines != null && !displayLines.isEmpty()) { - // Afficher les lignes formatées - for (String line : displayLines) { - System.out.println(line); - } - } - } + if (!silent && displayLines != null && !displayLines.isEmpty()) { + boolean isFirstLine = true; + for (String line : displayLines) { + if (isFirstLine) { + // Pour la première ligne, supprimer l'indentation + if (line.startsWith("\t")) { + System.out.println(line.substring(1)); + } else { + System.out.println(line); + } + isFirstLine = false; + } else { + // Pour les lignes suivantes, conserver l'indentation + System.out.println(line); + } + } + } + } // On n'exécute que si nécessaire if (ruleNeedsUpdate) { try { if(!isCircular && !silent){ - // Afficher les lignes formatées - if (displayLines != null && !displayLines.isEmpty()) { - for (String line : displayLines) { - System.out.println(line); - } - } else { - System.out.println(command); - } - } + // Afficher les lignes formatées avec traitement spécial pour les continuations + if (displayLines != null && !displayLines.isEmpty()) { + boolean isFirstLine = true; + + for (String line : displayLines) { + if (isFirstLine) { + // Pour la première ligne, toujours supprimer l'indentation + if (line.startsWith("\t")) { + System.out.println(line.substring(1)); + } else { + System.out.println(line); + } + isFirstLine = false; + } else { + // Pour les lignes suivantes d'une continuation, conserver l'indentation + System.out.println(line); + } + } + } else { + // Cas d'une commande simple (une seule ligne) + if (command.startsWith("\t")) { + System.out.println(command.substring(1)); + } else { + System.out.println(command); + } + } + } if (debug) System.out.println("Debug: Executing " + actualCommand); ProcessBuilder pb = new ProcessBuilder("sh", "-c", actualCommand); pb.inheritIO();