Why does sh interpret these commands differently to zsh?
问题 Context: I am trying to get the names of fonts installed on my Linux machine. The name is between two colons. When I run this script using zsh, it works. When I switch to sh it breaks. It probably deletes \n characters, because the output is all one line. cmd="$(fc-list)" names="$(echo $cmd | grep -oP "(?<=: ).*?(?=:)")" echo $names Which command causes the issues? Is it not POSIX compliant? 回答1: Why does sh interpret these commands differently to zsh? Because they are different shell the