standards: User Interfaces

1 
1 4.5 Standards for Interfaces Generally
1 ======================================
1 
1 Please don't make the behavior of a utility depend on the name used to
1 invoke it.  It is useful sometimes to make a link to a utility with a
1 different name, and that should not change what it does.
1 
1    Instead, use a run time option or a compilation switch or both to
1 select among the alternate behaviors.  You can also build two versions
1 of the program, with different names and different default behaviors.
1 
1    Likewise, please don't make the behavior of a command-line program
1 depend on the type of output device it gets as standard output or
1 standard input.  Device independence is an important principle of the
1 system's design; do not compromise it merely to save someone from typing
1 an option now and then.  (Variation in error message syntax when using a
1 terminal is ok, because that is a side issue that people do not depend
1 on.)
1 
1    If you think one behavior is most useful when the output is to a
1 terminal, and another is most useful when the output is a file or a
1 pipe, then it is usually best to make the default behavior the one that
1 is useful with output to a terminal, and have an option for the other
1 behavior.  You can also build two different versions of the program with
1 different names.
1 
1    There is an exception for programs whose output in certain cases is
1 binary data.  Sending such output to a terminal is useless and can cause
1 trouble.  If such a program normally sends its output to stdout, it
1 should detect, in these cases, when the output is a terminal and give an
1 error message instead.  The '-f' option should override this exception,
1 thus permitting the output to go to the terminal.
1 
1    Compatibility requires certain programs to depend on the type of
1 output device.  It would be disastrous if 'ls' or 'sh' did not do so in
1 the way all users expect.  In some of these cases, we supplement the
1 program with a preferred alternate version that does not depend on the
1 output device type.  For example, we provide a 'dir' program much like
1 'ls' except that its default output format is always multi-column
1 format.
1