Command-line syntax (read)
All REPLs start by reading some input. On the Linux command line, commands that the shell reads in need to have the correct syntax. Commands take this basic form:
commandname options
In programming terms, you can think of the command name as a function name, and the options as any number of arguments that will be passed to that function. This is important, because there is no single fixed syntax for all the options – each command defines which parameters it will accept. Because of this, the shell can do very little to validate a command’s correctness beyond checking that the command maps to an executable.
Note
The terms “program” and “command” are used interchangeably in this chapter. There’s a very slight difference because some shell builtins are defined in the shell’s code and are therefore not technically separate programs of their own, but you don’t need to worry...