Sample Header Ad - 728x90

Details with bash's syntax checking and breaking over several lines

0 votes
4 answers
96 views
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?
Asked by Bastian (25 rep)
Dec 16, 2024, 04:10 PM
Last activity: Dec 17, 2024, 09:26 AM