fix: capture init script exit codes instead of swallowing via pipe

Address review feedback: the pipe to sed swallowed the script's exit
code. Now capture output in a variable and check exit status separately
so failures are logged as warnings in the entrypoint output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
JayMishra-github
2026-02-16 10:47:14 -08:00
committed by Peter Steinberger
parent 53af9f7437
commit 8b14052ebe

View File

@@ -18,7 +18,8 @@ if [ -d "$INIT_DIR" ] && [ "$(ls -A "$INIT_DIR" 2>/dev/null)" ]; then
[ -f "$script" ] || continue
if [ -x "$script" ]; then
echo "[openclaw-init] Running $(basename "$script")..."
"$script" 2>&1 | sed "s/^/ /"
output=$("$script" 2>&1) || echo "[openclaw-init] WARNING: $(basename "$script") exited with status $?"
[ -n "$output" ] && printf '%s\n' "$output" | sed 's/^/ /'
else
echo "[openclaw-init] Skipping $(basename "$script") (not executable)"
fi