From 61104d1e25251c9fae81563abd98edc1c9c4c292 Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Fri, 2 Oct 2026 21:22:21 +0200 Subject: [PATCH] sync-library.sh: run the closing report under sh, not the remote login shell The report was an ssh command string, which the remote user's login shell runs - and on the devices root's is fish, which rejects `if ...; then`. The copy itself finished, but the script then exited 127 at the very end, so a successful sync looked failed. Feed the report to `sh -s` on stdin instead. Co-Authored-By: Claude Opus 5.5 --- scripts/sync-library.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/sync-library.sh b/scripts/sync-library.sh index c81e7b3..1af1660 100755 --- a/scripts/sync-library.sh +++ b/scripts/sync-library.sh @@ -224,14 +224,17 @@ if [[ $DRY_RUN -eq 1 ]]; then exit 0 fi -ssh "$SSH_TARGET" " - echo 'library: '\$(du -sh '$DEST' 2>/dev/null | cut -f1) - echo 'free: '\$(df -Ph '$DEST' | awk 'NR==2 {print \$4}') - if [ -d '${DEST}/.musicmouse-cache' ]; then - echo 'covers: '\$(find '${DEST}/.musicmouse-cache/covers' -type f 2>/dev/null | wc -l)' files' - echo 'analysis: '\$(find '${DEST}/.musicmouse-cache/analysis' -type f 2>/dev/null | wc -l)' files' - fi -" +# Through `sh -s` rather than as an ssh command string: that string is run by the +# remote user's login shell, and on the devices root's is fish, which rejects +# `if ...; then`. The heredoc expands $DEST here; the escaped \$ ones run remotely. +ssh "$SSH_TARGET" sh -s </dev/null | cut -f1)" +echo "free: \$(df -Ph '$DEST' | awk 'NR==2 {print \$4}')" +if [ -d '${DEST}/.musicmouse-cache' ]; then + echo "covers: \$(find '${DEST}/.musicmouse-cache/covers' -type f 2>/dev/null | wc -l) files" + echo "analysis: \$(find '${DEST}/.musicmouse-cache/analysis' -type f 2>/dev/null | wc -l) files" +fi +EOF cat <