[TUHS] Why does shell write to stderr?

Steffen Nurpmeso steffen at sdaoden.eu
Fri Apr 8 07:32:34 AEST 2022


Douglas McIlroy wrote in
 <CAKH6PiXBEZPyjUk=DD8moA8ZnA2kpfk=Z7+6WwckSQb5HPUX3Q at mail.gmail.com>:
 |How would you wish to interact with
 |        /bin/bash >file

While the POSIX standard defines an interactive shell as one with
STDIN and STDERR being a terminal, i think the NetBSD shell did
not until not too long (< half a decade?) ago, and the mailer you
were using for a long time does not to this day.  (Unfortunately.)

  APPLICATION USAGE
  Standard input and standard error are the files that determine
  whether a shell is interactive when -i is not specified. For
  example:

    sh > file
  and:
    sh 2> file

  create interactive and non-interactive shells,
  respectively. Although both accept terminal input, the results of
  error conditions are different, as described in Section 2.8.1 (on
  page 2363); in the second example a redirection error encountered
  by a special built-in utility aborts the shell.

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)


More information about the TUHS mailing list