[prev] [index] [next]

What Shells Do

All Unix shells have the same basic mode of operation:

loop
   if (interactive) print a prompt
   read a line of user input
   apply transformations to line
   split line into words (/\s+/)
   use first word in line as command name
   execute that command,
      using other words as arguments
end loop

Note that "line of user input" could be a line from a file.

In that case, the shell is reading a "script" of commands and acting as a kind of programming language interpreter.