01 / 08
Last lesson's one line, made readable
Last lesson you wrote this.
[ $# -eq 0 ] && echo "name one" && exit 1It works, but as the things to do grow it gets hard to read. Three && in a row and you cannot tell where the condition ends.
The same thing can be written this way.
if [ $# -eq 0 ]; then echo "name one" exit 1fiThe condition and the doing have come apart. This is if.
You read it like this.
if ifthen thenfi that is the endfi is if written backwards, the mark for closing. The same job as the } of other languages.
And you can write the fork in the road.
if [ test ]; then this wayelse that wayfiWhich gives you the second of the three elements of a program.
1. run in order <- done in lesson 12. branch on a test <- today3. repeat <- the next lesson