fix syntax error in rewrite macro; if and fi in sh not endif