bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] posix-shell.m4: fix typo that made this test malfunction


From: Bruno Haible
Subject: Re: [PATCH] posix-shell.m4: fix typo that made this test malfunction
Date: Thu, 10 Jul 2008 12:35:55 +0200
User-agent: KMail/1.5.4

Paul Eggert wrote:
> Here are some quotes:
> 
>    1. "Function Definition Command"
>    
> <http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_09_05>
>    says "When a function is executed, it shall have the syntax-error and
>    variable-assignment properties described for special built-in
>    utilities in the enumerated list at the beginning of Special Built-In
>    Utilities."
> 
>    2. "Special Built-In Utilities" (e.g., 'eval', 'shift')
>    
> <http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_14>
>    says "Variable assignments specified with special built-in utilities
>    remain in effect after the built-in completes; this shall not be the
>    case with a regular built-in or other utility."
> 
>    3. "Shell Execution Environment"
>    
> <http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_12>
>    says "Utilities other than the special built-ins (see Special Built-In
>    Utilities) shall be invoked in a separate environment that consists of
>    the following. The initial value of these objects shall be the same as
>    that for the parent shell, except as noted below.... * Variables with
>    the export attribute, along with those explicitly exported for the
>    duration of the command, shall be passed to the utility environment
>    variables"

Here are two other quotes:

  4. "Simple Commands"
  
<http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_09_01>
  "A "simple command" is a sequence of optional variable assignments and
   redirections, in any sequence, optionally followed by words and
   redirections, terminated by a control operator.
   ...
   The words that are not variable assignments or redirections shall be
   expanded. If any fields remain following their expansion, the first field
   shall be considered the command name and remaining fields are the arguments
   for the command.
   ...
   If no command name results, variable assignments shall affect the current
   execution environment. Otherwise, the variable assignments shall be
   exported for the execution environment of the command and shall not
   affect the current execution environment (except for special built-ins).
   ...
   If there is a command name, execution shall continue as described in
   [Command Search and Execution]."

  5. "Command Search and Execution"
  
<http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_09_01_01>
  "If the command name does not contain any slashes, the first successful step
   in the following sequence shall occur:
   a. If the command name matches the name of a special built-in utility, ...
   b. If the command name matches the name of a function known to this shell,
      the function shall be invoked as described in [Function Definition
      Command].
   c. If the command name matches the name of a utility listed in the following
      table, ...
   d. Otherwise, the command shall be searched for using the PATH environment
      variable ...
   ..."

> So, there's no requirement that function executions be treated like
> ordinary commands as far as the "a=b f" syntax goes.

I disagree: Quote 4 does not distinguish function execution commands and
program invocation commands. It's only quote 5 which does, but quote 4
specifies that "the variable assignments shall be exported for the execution
environment of the command" regardless.

> On the contrary,
> it looks more the other way around: if F is a function, "a=b f" looks
> like it is supposed to be executed as if it were "a=b; f".

I disagree.
  - Quote 1 talks about variable assignments performed inside the
    function, which is not relevant here.
  - Quote 2 talks about things like "eval foo=2", which is also not
    relevant here.
  - Quote 3 says
      "Variables with the export attribute,
       *along with those explicitly exported for the duration of the command*,
       shall be passed to the utility environment variables".
    Together with quote 4 (and since the duration of a utility execution command
    inside a function is contained in the duration of the function execution
    command), "a=b f" must have 'a' exported during utility executions
    inside f.

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]