refactor: simplify pass (trekexecute)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-10-26 20:39:40 +01:00
commit 52c382c198
Signed by: ktg
SSH key fingerprint: SHA256:JakMjO6FTBBzN0Bhfj9saOoEjaFxlSdYuZQQpM/lF9Q
8 changed files with 45 additions and 52 deletions

View file

@ -270,13 +270,12 @@ const commandView = commandPositionView(deobfuscated.replace(/\x1B\[[0-9;]*m/g,
// only when exactly one line, trimmed, equals the delimiter and every line
// after it is empty.
const ARGS_DELIM = 'VOYAGE_ARGS_EOF_7F3C9E';
const argsOpener = /<<-?\s*(['"\\]?)VOYAGE_ARGS_EOF_7F3C9E(['"]?)/.exec(command);
const argsOpener = new RegExp(`<<-?\\s*(['"\\\\]?)${ARGS_DELIM}(['"]?)`).exec(command);
if (argsOpener) {
const [, open, close] = argsOpener;
const quoted = (open === '\\' && close === '') || (open !== '' && open !== '\\' && close === open);
const quoted = open === '\\' ? close === '' : open !== '' && close === open;
const lines = command.split('\n');
const closing = [];
lines.forEach((line, i) => { if (line.trim() === ARGS_DELIM) closing.push(i); });
const closing = lines.flatMap((l, i) => (l.trim() === ARGS_DELIM ? [i] : []));
const closesOnceAtEnd = closing.length === 1 &&
lines.slice(closing[0] + 1).every((line) => line.trim() === '');
if (!quoted || !closesOnceAtEnd) {