Splits a compound shell command into segments separated by &&, ||, ;.
Pipes (|) are treated specially: only the left side of a pipe is eligible
for rewriting (the right side consumes output format and must stay raw).
Rewrites a compound command by applying a rewrite function to each command segment.
Operators and pipe-right-hand segments are preserved unchanged.
rewrite_fn receives a command string and returns Some(rewritten) if it should
be rewritten, or None to keep the original.