docs/unix-phil

changeset 30:ec17b3a969c7

various minor rework in ch04
author meillo@marmaro.de
date Wed, 24 Mar 2010 22:07:02 +0100
parents 302daab2e8ee
children 0caa9760fca8
files unix-phil.ms
diffstat 1 files changed, 92 insertions(+), 58 deletions(-) [+]
line diff
     1.1 --- a/unix-phil.ms	Sun Mar 14 10:33:45 2010 +0100
     1.2 +++ b/unix-phil.ms	Wed Mar 24 22:07:02 2010 +0100
     1.3 @@ -656,9 +656,9 @@
     1.4  .NH 1
     1.5  Case study: \s-1MH\s0
     1.6  .LP
     1.7 -The last chapter introduced and explained the Unix Philosophy
     1.8 +The previous chapter introduced and explained the Unix Philosophy
     1.9  from a general point of view.
    1.10 -The driving force were the guidelines, references to
    1.11 +The driving force were the guidelines; references to
    1.12  existing software were given only sparsely.
    1.13  In this and the next chapter, concrete software will be
    1.14  the driving force in the discussion.
    1.15 @@ -677,8 +677,16 @@
    1.16  Historical background
    1.17  .LP
    1.18  Electronic mail was available in Unix very early.
    1.19 -The first \s-1MUA\s0 on Unix was \f(CWmail\fP.
    1.20 -It was a small program that either prints the own mailbox file
    1.21 +The first \s-1MUA\s0 on Unix was \f(CWmail\fP,
    1.22 +which was already present in the First Edition.
    1.23 +.[
    1.24 +%A Peter H. Salus
    1.25 +%T A Quarter Century of UNIX
    1.26 +%D 1994
    1.27 +%I Addison-Wesley
    1.28 +%P 41 f.
    1.29 +.]
    1.30 +It was a small program that either prints the user's mailbox file
    1.31  or appends text to someone elses mailbox file,
    1.32  depending on the command line arguments.
    1.33  .[
    1.34 @@ -702,13 +710,13 @@
    1.35  %A Gunnar Ritter
    1.36  %O http://heirloom.sourceforge.net/mailx_history.html
    1.37  .]
    1.38 -Elm, pine, mutt, and today a whole bunch of graphical \s-1MUA\s0s
    1.39 +Elm, pine, mutt, and a whole bunch of graphical \s-1MUA\s0s
    1.40  followed Mail's direction.
    1.41  They are large, monolithic programs which include all emailing functions.
    1.42  .PP
    1.43  A different way was taken by the people of \s-1RAND\s0 Corporation.
    1.44  In the beginning, they also had used a monolitic mail system,
    1.45 -called \s-1MS\s0 simply for ``mail system''.
    1.46 +called \s-1MS\s0 (for ``mail system'').
    1.47  But in 1977, Stockton Gaines and Norman Shapiro
    1.48  came up with a proposal of a new email system concept \(en
    1.49  one that honors the Unix Philosophy.
    1.50 @@ -744,16 +752,17 @@
    1.51  Contrasts to monolithic mail systems
    1.52  .LP
    1.53  All \s-1MUA\s0s are monolithic, except \s-1MH\s0.
    1.54 -This might not be true,
    1.55 -but it reflects the situation pretty well.
    1.56 +Although there might acutally exist further, very little known,
    1.57 +toolchest \s-1MUA\s0s, this statement reflects the situation pretty well.
    1.58  .PP
    1.59 -While monolithic \s-1MUA\s0s gather all function in one program,
    1.60 -\s-1MH\s0 is a toolchest of many small tools \(en one for each job.
    1.61 +Monolithic \s-1MUA\s0s gather all their functions in one program.
    1.62 +In contrast, \s-1MH\s0 is a toolchest of many small tools \(en one for each job.
    1.63  Following is a list of important programs of \s-1MH\s0's toolchest
    1.64 -and their function:
    1.65 +and their function.
    1.66 +It gives a feeling of how the toolchest looks like.
    1.67  .IP \(bu
    1.68  .CW inc :
    1.69 -incorporate new mail
    1.70 +incorporate new mail (this is how mail enters the system)
    1.71  .IP \(bu
    1.72  .CW scan :
    1.73  list messages in folder
    1.74 @@ -783,24 +792,27 @@
    1.75  forward a message
    1.76  .IP \(bu
    1.77  .CW send : 
    1.78 -send a prepared message
    1.79 +send a prepared message (this is how mail leaves the system)
    1.80  .LP
    1.81  \s-1MH\s0 has no special user interface like monolithic \s-1MUA\s0s have.
    1.82  The user does not leave the shell to run \s-1MH\s0,
    1.83 -but he uses \s-1MH\s0 within the shell.
    1.84 +but he uses the various \s-1MH\s0 programs within the shell.
    1.85  Using a monolithic program with a captive user interface
    1.86  means ``entering'' the program, using it, and ``exiting'' the program.
    1.87  Using toolchests like \s-1MH\s0 means running programs,
    1.88  alone or in combinition with others, even from other toolchests,
    1.89  without leaving the shell.
    1.90 -.PP
    1.91 +
    1.92 +.NH 2
    1.93 +Data storage
    1.94 +.LP
    1.95  \s-1MH\s0's mail storage is (only little more than) a directory tree
    1.96  where mail folders are directories and mail messages are text files.
    1.97  Working with \s-1MH\s0's toolchest is much like working
    1.98  with Unix' toolchest:
    1.99  \f(CWscan\fP is like \f(CWls\fP,
   1.100  \f(CWshow\fP is like \f(CWcat\fP,
   1.101 -\f(CWfolder\fP is like \f(CWcd\fP,
   1.102 +\f(CWfolder\fP is like \f(CWcd\fP/\f(CWpwd\fP,
   1.103  \f(CWrefile\fP is like \f(CWmv\fP,
   1.104  and \f(CWrmm\fP is like \f(CWrm\fP.
   1.105  .PP
   1.106 @@ -821,6 +833,35 @@
   1.107  which appears to be a legacy.
   1.108  This will cause problems when multiple users work
   1.109  in one mail folder simultaneously.
   1.110 +.PP
   1.111 +.I "Data storage.
   1.112 +How \s-1MH\s0 stores data was already mentioned.
   1.113 +Mail folders are directories (which contain a file
   1.114 +\&\f(CW.mh_sequences\fP) under the user's \s-1MH\s0 directory
   1.115 +(usually \f(CW$HOME/Mail\fP).
   1.116 +Mail messages are text files located in mail folders.
   1.117 +The files contain the messages as they were received.
   1.118 +The messages are numbered in ascending order in each folder.
   1.119 +This mailbox format is called ``\s-1MH\s0'' after the \s-1MUA\s0.
   1.120 +Alternatives are \fImbox\fP and \fImaildir\fP.
   1.121 +In the mbox format all messages are stored within one file.
   1.122 +This was a good solution in the early days, when messages
   1.123 +were only a few lines of text and were deleted soon.
   1.124 +Today, when single messages often include several megabytes
   1.125 +of attachments, it is a bad solution.
   1.126 +Another disadvantage of the mbox format is that it is
   1.127 +more difficult to write tools that work on mail messages,
   1.128 +because it is always necessary to first find and extract
   1.129 +the relevant message in the mbox file.
   1.130 +With the \s-1MH\s0 mailbox format,
   1.131 +each message is a self-standing item, by definition.
   1.132 +Also, the problem of concurrent access to one mailbox is
   1.133 +reduced to the problem of concurrent access to one message.
   1.134 +However, the issue of the shared parts of the context,
   1.135 +as mentioned above, remains.
   1.136 +Maildir is generally similar to \s-1MH\s0's format,
   1.137 +but modified towards guaranteed reliability.
   1.138 +This involves some complexity, unfortunately.
   1.139  
   1.140  
   1.141  .NH 2
   1.142 @@ -865,45 +906,19 @@
   1.143  functionality with little work.
   1.144  
   1.145  .PP
   1.146 -.I "Data storage.
   1.147 -How \s-1MH\s0 stores data was already mentioned.
   1.148 -Mail folders are directories (which contain a file
   1.149 -\&\f(CW.mh_sequences\fP) under the user's \s-1MH\s0 directory
   1.150 -(usually \f(CW$HOME/Mail\fP).
   1.151 -Mail messages are text files located in mail folders.
   1.152 -The files contain the messages as they were received.
   1.153 -The messages are numbered in ascending order in each folder.
   1.154 -This mailbox format is called ``\s-1MH\s0'' after the \s-1MUA\s0.
   1.155 -Alternatives are \fImbox\fP and \fImaildir\fP.
   1.156 -In the mbox format all messages are stored within one file.
   1.157 -This was a good solution in the early days, when messages
   1.158 -were only a few lines of text and were deleted soon.
   1.159 -Today, when single messages often include several megabytes
   1.160 -of attachments, it is a bad solution.
   1.161 -Another disadvantage of the mbox format is that it is
   1.162 -more difficult to write tools that work on mail messages,
   1.163 -because it is always necessary to first find and extract
   1.164 -the relevant message in the mbox file.
   1.165 -With the \s-1MH\s0 mailbox format,
   1.166 -each message is a self-standing item, by definition.
   1.167 -Also, the problem of concurrent access to one mailbox is
   1.168 -reduced to the problem of concurrent access to one message.
   1.169 -However, the issue of the shared parts of the context,
   1.170 -as mentioned above, remains.
   1.171 -Maildir is generally similar to \s-1MH\s0's format,
   1.172 -but modified towards guaranteed reliability.
   1.173 -This involves some complexity, unfortunately.
   1.174 +.I "Store data in flat text files.
   1.175 +FIXME
   1.176  
   1.177  .PP
   1.178  .I "``Avoid captive user interfaces.''
   1.179  \s-1MH\s0 is perfectly suited for non-interactive use.
   1.180  It offers all functions directly and without captive user interfaces.
   1.181 -If users want a graphical user interface, anyhow,
   1.182 +If, nonetheless, users want a graphical user interface,
   1.183  they can have it with \fIxmh\fP or \fIexmh\fP, too.
   1.184  These are graphical frontends for the \s-1MH\s0 toolchest.
   1.185  This means, all email-related work is still done by \s-1MH\s0 tools,
   1.186  but the frontend issues the appropriate calls when the user
   1.187 -clicks on a button.
   1.188 +clicks on buttons.
   1.189  Providing easy-to-use user interfaces in form of frontends is a good
   1.190  approach, because it does not limit the power of the backend itself.
   1.191  The frontend will anyway only be able to make a subset of the
   1.192 @@ -911,22 +926,25 @@
   1.193  But if it is a separate program,
   1.194  then the missing parts can still be accessed at the backend directly.
   1.195  If it is integrated, then this will hardly be possible.
   1.196 +Further more, it is possible to have different frontends to the same
   1.197 +backend.
   1.198  
   1.199  .PP
   1.200  .I "``Choose portability over efficiency''
   1.201  and
   1.202  .I "``use shell scripts to increase leverage and portability'' .
   1.203  These two tenets are indirectly, but nicely, demonstrated by
   1.204 -Bolsky and Korn in their book about the korn shell.
   1.205 +Bolsky and Korn in their book about the Korn Shell.
   1.206  .[
   1.207  %T The KornShell: command and programming language
   1.208  %A Morris I. Bolsky
   1.209  %A David G. Korn
   1.210  %I Prentice Hall
   1.211  %D 1989
   1.212 +%P 254\(en290
   1.213  %O \s-1ISBN\s0: 0-13-516972-0 
   1.214  .]
   1.215 -They demonstrated, in one chapter of the book, a basic implementation
   1.216 +They demonstrated, in chapter 18 of the book, a basic implementation
   1.217  of a subset of \s-1MH\s0 in ksh scripts.
   1.218  Of course, this was just a demonstration, but a brilliant one.
   1.219  It shows how quickly one can implement such a prototype with shell scripts,
   1.220 @@ -938,7 +956,12 @@
   1.221  to be widespread.
   1.222  This demonstration also shows how easy it is to create single programs
   1.223  of a toolchest software.
   1.224 -Most of them comprise less than a hundred lines of shell code.
   1.225 +There are eight tools (two of them have multiple names) and 16 functions
   1.226 +with supporting code.
   1.227 +Each tool comprises between 12 and 38 lines of ksh,
   1.228 +in total about 200 lines.
   1.229 +The functions comprise between 3 and 78 lines of ksh,
   1.230 +in total about 450 lines.
   1.231  Such small software is easy to write, easy to understand,
   1.232  and thus easy to maintain.
   1.233  A toolchest improves the possibility to only write some parts
   1.234 @@ -952,17 +975,18 @@
   1.235  .I "``allow the user to tailor the environment''
   1.236  are ideally followed in the design of \s-1MH\s0.
   1.237  Tailoring the environment is heavily encouraged by the ability to
   1.238 -directly define default options to programs, even different ones
   1.239 +directly define default options to programs.
   1.240 +It is even possible to define different default options
   1.241  depending on the name under which the program was called.
   1.242  Software leverage is heavily encouraged by the ease it is to
   1.243  create shell scripts that run a specific command line,
   1.244 -build of several \s-1MH\s0 programs.
   1.245 +built of several \s-1MH\s0 programs.
   1.246  There is few software that so much wants users to tailor their
   1.247  environment and to leverage the use of the software, like \s-1MH\s0.
   1.248  Just to make one example:
   1.249  One might prefer a different listing format for the \f(CWscan\fP
   1.250  program.
   1.251 -It is possible to take one of the other distributed format files
   1.252 +It is possible to take one of the distributed format files
   1.253  or to write one yourself.
   1.254  To use the format as default for \f(CWscan\fP, a single line,
   1.255  reading
   1.256 @@ -975,7 +999,7 @@
   1.257  instead of changing the default, he needs to create a link to
   1.258  \f(CWscan\fP, for instance titled \f(CWscan2\fP.
   1.259  The line in \f(CW.mh_profile\fP would then start with \f(CWscan2\fP,
   1.260 -as the option should only be in effect when scan was called as
   1.261 +as the option should only be in effect when scan is called as
   1.262  \f(CWscan2\fP.
   1.263  
   1.264  .PP
   1.265 @@ -983,11 +1007,17 @@
   1.266  is hard to find in \s-1MH\s0.
   1.267  The reason therefore is that most of \s-1MH\s0's tools provide
   1.268  basic file system operations for the mailboxes.
   1.269 +The reason is the same because of which
   1.270  \f(CWls\fP, \f(CWcp\fP, \f(CWmv\fP, and \f(CWrm\fP
   1.271  aren't filters neither.
   1.272  However, they build a basis on which filters can operate.
   1.273  \s-1MH\s0 does not provide many filters itself, but it is a basis
   1.274  to write filters for.
   1.275 +An example would be a mail message text highlighter,
   1.276 +that means a program that makes use of a color terminal to display
   1.277 +header lines, quotations, and signatures in distinct colors.
   1.278 +The author's version of this program, for instance,
   1.279 +is a 25 line awk script.
   1.280  
   1.281  .PP
   1.282  .I "``Build a prototype as soon as possible''
   1.283 @@ -999,7 +1029,7 @@
   1.284  to ever create \s-1MH\s0.
   1.285  In Bruce' own words:
   1.286  .QP
   1.287 -[...] but [Stockton Gaines and Norm Shapiro] were not able
   1.288 +[...] but they [Stockton Gaines and Norm Shapiro] were not able
   1.289  to convince anyone that such a system would be fast enough to be usable.
   1.290  I proposed a very short project to prove the basic concepts,
   1.291  and my management agreed.
   1.292 @@ -1019,7 +1049,7 @@
   1.293  Problems
   1.294  .LP
   1.295  \s-1MH\s0, for sure is not without problems.
   1.296 -There are two main problems: one technical, the other about human behavior.
   1.297 +There are two main problems: one is technical, the other is about human behavior.
   1.298  .PP
   1.299  \s-1MH\s0 is old and email today is very different to email in the time
   1.300  when \s-1MH\s0 was designed.
   1.301 @@ -1032,15 +1062,19 @@
   1.302  \s-1IMAP\s0, for example, conflicts with \s-1MH\s0's design to a large extend.
   1.303  These design conflicts are not easily solvable.
   1.304  Possibly, they require a redesign.
   1.305 +Maybe \s-1IMAP\s0 is too different to the classic mail model which \s-1MH\s0 covers,
   1.306 +hence \s-1MH\s0 may never work well with \s-1IMAP\s0.
   1.307  .PP
   1.308  The other kind of problem is human habits.
   1.309  When in this world almost all \s-1MUA\s0s are monolithic,
   1.310  it is very difficult to convince people to use a toolbox style \s-1MUA\s0
   1.311  like \s-1MH\s0.
   1.312  The habits are so strong, that even people who understood the concept
   1.313 -and advantages of \s-1MH\s0 do not like to switch.
   1.314 -Unfortunately, the frontends to \s-1MH\s0, which can provide familiar look'n'feel,
   1.315 -are not very appealing in contrast to what monolithic \s-1MUA\s0s offer.
   1.316 +and advantages of \s-1MH\s0 do not like to switch,
   1.317 +simply because \s-1MH\s0 is different.
   1.318 +Unfortunately, the frontends to \s-1MH\s0, which could provide familiar look'n'feel,
   1.319 +are quite outdated and thus not very appealing compared to the modern interfaces
   1.320 +which monolithic \s-1MUA\s0s offer.
   1.321  
   1.322  .NH 2
   1.323  Summary \s-1MH\s0