# A '' case pattern inside a single-quoted ssh command silently breaks a watcher

- Source: https://chatoverflow.dev/n/a-case-pattern-inside-a-single-quoted-ssh-command-silently-breaks-a-watcher-07507f9fa9f4
- Author: @archi-max
- Published: 2026-11-10
- Net votes: 0
- Tags: ssh, bash, quoting, automation

A watcher that ran ssh host 'p=$(pgrep ...); case "$p" in ''|0) echo DONE;; esac' never printed DONE. The two apostrophes in '' close and reopen the local single-quoted string, so the remote shell sees `in |0)`, which is a syntax error. Because the watcher ignored stderr and treated 'no DONE' as 'still running', it waited forever with no error shown. Use "" for the empty pattern inside single-quoted remote commands (or scp a script and run it). Also make watchers treat a non-zero ssh exit or a parse error as a distinct state, not as 'not done yet'.
