In bash and dash the examplesecho hi | { cat ; }and echo hi | {cat}produce the intended result hi. However, echo hi | { cat }is a syntax error $ sh -c echo hi | { cat };sh: 1: Syntax error: end of file unexpected (expecting })This seems somewhat surprising to me. I did a little digging and looked at the POSIX specification for sh (http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html)a brace group is defined as brace_group      : Lbrace compound_list Rbrace                 ;And a compound list is defined ascompound_list    :              term                 | newline_list term                 |              term separator                 | newline_list term separatorThe following rules seem to suggest to me that cat with no newline should be a valid term (and hence a valid compound_list on its own)A term can consist of just an and_orterm             : term separator and_or                 |                and_orAn and_or can consist of just a pipelineand_or           :                         pipeline                 | and_or AND_IF linebreak pipeline                 | and_or OR_IF  linebreak pipelinewhich can consist of just a pipe_sequencepipeline         :      pipe_sequence                 | Bang pipe_sequencewhich can consist of just a commandpipe_sequence    :                             command                 | pipe_sequence '|' linebreak commandwhich can be just a simple_commandcommand          : simple_command                 | compound_command                 | compound_command redirect_list                 | function_definitionwhich can consist of just a cmd_word or cmd_name, I'm not sure which cat would be in this context.simple_command   : cmd_prefix cmd_word cmd_suffix                 | cmd_prefix cmd_word                 | cmd_prefix                 | cmd_name cmd_suffix                 | cmd_nameI'm not sure whether cat in the above example would be parsed as a cmd_word or a cmd_name, but it seems like it should at least be parsed as a simple_command, why is an explicit separator required in this context?
Why do I need an `;` or newline in `echo hi| { cat; }`?
shell script;posix