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 <