[FIX] script todo: ~/.ssh/config entry wiped following blocks
_write_ssh_config_entry used a DOTALL (?ms) regex to remove an existing "Host <name>" block; with DOTALL, ".*" crossed newlines and matched from the block to the end of the file, so re-adding an already-present host deleted every entry after it. Dropping DOTALL (keep MULTILINE, match indented lines with [^\n]*) removes only the target block and preserves the rest. Not a parallelism issue — the writes are sequential. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
990c81c0e7
commit
c4f7d7dcbd
1 changed files with 6 additions and 3 deletions
|
|
@ -1083,10 +1083,13 @@ class TODO:
|
|||
if os.path.exists(cfg):
|
||||
with open(cfg, encoding="utf-8") as fh:
|
||||
existing = fh.read()
|
||||
# Retire un ancien bloc du même Host (jusqu'au prochain Host / EOF).
|
||||
# Retire un ancien bloc du même Host (ses lignes indentées). Pas de
|
||||
# drapeau DOTALL : « . » ne doit PAS traverser les sauts de ligne,
|
||||
# sinon .* engloutirait tout jusqu'à la fin du fichier et effacerait
|
||||
# les entrées suivantes.
|
||||
pattern = re.compile(
|
||||
rf"(?ms)^[ \t]*Host[ \t]+{re.escape(host)}[ \t]*\n"
|
||||
r"(?:[ \t]+.*\n?)*"
|
||||
rf"(?m)^[ \t]*Host[ \t]+{re.escape(host)}[ \t]*\n"
|
||||
r"(?:[ \t]+[^\n]*\n?)*"
|
||||
)
|
||||
existing = pattern.sub("", existing).rstrip("\n")
|
||||
block = (
|
||||
|
|
|
|||
Loading…
Reference in a new issue