ugh.book

(singke) #1

150 csh, pipes, and find


to any C-shell will cause it to crash immediately? Do you know why?

Questions to think about:


  • What does the shell do when you type “!xxx”?

  • What must it be doing with your input when you type
    “!xxx%s%s%s%s%s%s%s%s”?

  • Why does this crash the shell?

  • How could you (rather easily) rewrite the offending part of the shell
    so as not to have this problem?


MOST IMPORTANTLY:


  • Does it seem reasonable that you (yes, you!) can bring what may be
    the Future Operating System of the World to its knees in 21 key-
    strokes?


Try it. By Unix’s design, crashing your shell kills all your processes and
logs you out. Other operating systems will catch an invalid memory refer-
ence and pop you into a debugger. Not Unix.

Perhaps this is why Unix shells don’t let you extend them by loading new
object code into their memory images, or by making calls to object code in
other programs. It would be just too dangerous. Make one false move
and—bam—you’re logged out. Zero tolerance for programmer error.

The Metasyntactic Zoo
The C Shell’s metasyntactic operator zoo results in numerous quoting
problems and general confusion. Metasyntactic operators transform a com-
mand before it is issued. We call the operators metasyntactic because they
are not part of the syntax of a command, but operators on the command
itself. Metasyntactic operators (sometimes called escape operators) are
familiar to most programmers. For example, the backslash character (\)
within strings in C is metasyntactic; it doesn’t represent itself, but some
operation on the following characters. When you want a metasyntactic
operator to stand for itself, you have to use a quoting mechanism that tells
the system to interpret the operator as simple text. For example, returning
to our C string example, to get the backslash character in a string, it is nec-
essary to write \\.
Free download pdf