WG15 Defect Report Ref: 9945-2-110
Topic: shell - ENV

This is an approved interpretation of 9945-2:1993.


Last update: 1997-05-20



	Topic:                  shell - ENV
	Relevant Sections:      3.5.3

Defect Report:

	From: dgk@research.att.com
	Date: Wed, 19 Apr 95 17:29:02 EDT

       Dear Interpretations Board:

       I would like an interpretation of the scope of the ENV
       environment variable as described in the 9945-2:1993 Shell
       and Utilities Standard.

       In Section 3.5.3, page 123, lines 242-252 the standard says,
       "This variable, when the shell is invoked, shall be ... This
       standard specifies the effects of this variable only for
       systems supporting the User Portability Utilities Option."

       It isn't clear whether or not, non-interactive shells, and
       shell scripts are required to expand and use the ENV file.
       Behavior varies from one implementation to another and
       overall system performance can be effected.

       At the time that the UPE was removed and put into a
       separately balloted standard, there was discussion that
       indicated that the shell used for system() didn't have to
       support UPE extensions even on UPE systems, since portable
       scripts could not rely on the UPE.  However, if systems that
       support UPE require ENV to be expanded for each call to
       system(), then this dichotomy into two shells would not be
       possible unless the standard is changed to provide an
       explicit exception for this.

       More importantly, if systems that support UPE are required
       to process ENV files for non-interactive shells, then it is
       impossible to write scripts that have predictable behavior.
       For example, if the ENV file does a set or shift, then the
       arguments seen by the script will differ than the ones given
       by the user.  Unlike, aliases, functions, and options that
       are set in the ENV, there is no way for the script to work
       around these changes.

       In addition, the standard doesn't specify when a shell will
       be invoked.  For example, if foo is a script, will running
       foo invoke a shell?  Current implementations vary.  Some
       implementations will always invoked a new shell.  Others,
       only if the line, #! /bin/sh is the first line of the
       script; others, never.  This leads to unpredictable

       I believe that the standard is unclear about when ENV is to
       be used on systems that support the UPE.  The current
       wording is the result of editorial choice that occurred when
       merging two separately balloted standards.  The wording in
       the standard should be changed to make it clear that for
       systems that support UPE, ENV is only required to be used
       for interactive shells.

                                               Sincerely yours,

                                               David Korn

David Korn

Interpretation response
The standard states the behavior for the ENV environment variable, and 
conforming implementations must conform to this.  However, concerns have 
been raised about this which are being referred to the sponsor.


Forwarded to Interpretations group: Apr 20 1995
Proposed resolution circulated: May 16th
Comments due: June 15th
Finalised: June 16th 1995