There are two cases in which I do not understand why bash behaves as it behaves regarding syntax checking and asking for a newline.
Case 1
bash can execute the line ( (ls) | cat)
, but depending on when you hit return while entering, it might work or not.
This works:
( (ls ) |⏎
cat
This fails:
( (ls) ⏎
| cat)
with error
-bash: syntax error near unexpected token `|'
Is there a logic why the second case is not working? Or it is just how bash works internally?
Case 2
Another thing I do not understand is, that, when you enter (ls) "⏎
bash asks for another line. Is there any way to finish this command without getting a syntax error? And if not, why does bash not directly print out an error message for a syntax error?