Answer to CommandShell exercise
Last updated at 3:12 pm UTC on 8 March 2018
The fourth command will generate an error.
- Line one is evaluated as a complete Smalltalk expression, and succeeds.
- Line two is evaluated as a complete Smalltalk expression, and succeeds.
- Line three is evaluated as a pipeline after failing evaluation as a complete Smalltalk expression. It succeeds as a pipeline with one internal doIt proxy, and produces the same output as line one.
- Line four cannot be evaluated as a complete Smalltalk expression. The ";" token causes the command line to be evaluated as two pipelines. The expression for the first pipeline does not have a trailing "!" token, so it is assumed to be an external command, and fails. The second pipeline is evaluated as a doIt on the string 'cr!', which fails as an invalid Smalltalk expression. The error messages for both failures are accumulated on the shared error pipe, and are displayed in the terminal window.
- Line five is evaluated successfully as two pipelines, each consisting of one doIt proxy. The output is the same as for line two.