From 0283fa196a17e8e39767833716edc4ac9a5c8812 Mon Sep 17 00:00:00 2001 From: Lars Date: Thu, 29 Oct 2026 18:18:34 +0100 Subject: [PATCH] fix(restore): pass SQL via stdin to avoid newline escaping issues in psql_exec --- scripts/shinkan/shinkan-restore | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/shinkan/shinkan-restore b/scripts/shinkan/shinkan-restore index a356167..674199e 100644 --- a/scripts/shinkan/shinkan-restore +++ b/scripts/shinkan/shinkan-restore @@ -101,12 +101,11 @@ def write_result(path, data): def psql_exec(tcfg, dbname, sql): cmd = [ - 'docker', 'exec', tcfg['db_container'], + 'docker', 'exec', '-i', tcfg['db_container'], 'sh', '-ec', - 'export PGPASSWORD="${POSTGRES_PASSWORD:-}"; ' - f'psql -v ON_ERROR_STOP=1 -U "{tcfg["db_user"]}" -d "{dbname}" -At -c ' + json.dumps(sql), + f'export PGPASSWORD="${{POSTGRES_PASSWORD:-}}"; exec psql -v ON_ERROR_STOP=1 -U "{tcfg["db_user"]}" -d "{dbname}" -At', ] - return subprocess.run(cmd, capture_output=True, text=True, timeout=60) + return subprocess.run(cmd, input=sql, capture_output=True, text=True, timeout=60) def drop_db_if_exists(tcfg, dbname):