[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: everyone's least favorite creatures



Lest we replace the trimming knife with a hatchet, I'd like to
make some comments on features.

We all know why features are bad: primarily, each extra line in the man
pages is something else to hold in our limited memories and distract our
limited minds, and also each extra line of code introduces the
possibilities for further bugs, and increases the size of the
executable.

But why and when are features good?  When they provide support for
portability and inter-operability.  

For example, if everyone were to write their own "cd", with cdpath
searching, symbolic link following, directory stacks, home directory
support, directory echoing, and so on, I'm sure each of us would write
something slightly different to all of the others.  But that wouldn't
matter, because I doubt anyone will write a utility for general
consumption which relies on the explicit behaviour of cd beyond "cd
/absolute/path" or "cd relative/path".

However, if each of us were to write our own "read", some reading from
stdin, others from /dev/tty, some reading a whole line, others single
tokens, some performing assignment, others writing to stdout, and others
returning a value, and all of us indicating EOF or other failures in our
own favorite ways.  We would have a tool which was completely useless
for portable programs -- no one could rely on it and each would have to
supply their own.  How much better would it be to have a single,
well-definedi, ubiquitous, and bug-free (one would hope) tool?

So, as I see it we have four kinds of features:

   (a) Those necessary to provide the essential functions of a shell,
       e.g., %cd, %or, %background.

   (b) Those useful to interactive users, but otherwise of not essential,
       e.g., cd with path searching, mapping ~ to home, syntactic sugar.

   (c) Those useful to portable programming, e.g., a read.  These features
       form the `libc' of es, along with sed, et al.

   (d) Tacky features which should never have made it onto the man page,
       e.g., `word rather than `{word}.  (Sorry, Paul, I couldn't resist.)

I guess we also have:

   (e) Features which are there for efficiency, e.g., echo over /bin/echo
       (although because of -n and -- this is arguably in category (c)),
       and fspilt over some dance involving sed.

Now, the real debate should be which features are in categories (a),
(b), (c), or (e), and so have at least some claim to legitimacy, and
precisely how far into (b) do we want to go (i.e., we should keep
syntactic sugar, but do we need to keep ~ and cdpathsearch as builtins
-- why can't people use sed on ypcat or perform the search themselves?).
When I get some time to think about this, I'll reply with my own
preferences and prejudices.

Alan.