Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0001194 [1003.1(2016/18)/Issue7+TC2] Shell and Utilities Editorial Clarification Requested 2018-04-23 18:10 2019-11-08 11:51
Reporter steffen View Status public  
Assigned To
Priority normal Resolution Accepted As Marked  
Status Applied  
Name steffen
Organization
User Reference
Section vol. 3: sh
Page Number 3239
Line Number 108848
Interp Status ---
Final Accepted Text Note: 0004304
Summary 0001194: sh: mention historic function body in APPLICATION USAGE
Description Unix Version 8 shell and others documented functions as

     name () command
            Define a function which is referenced by name. The body of the
            function is the command. The most useful form of command is a
            sequence of commands enclosed by { and }. Execution of
            functions is described below (see Execution).

Where command was

     A command is either a simple-command or one of the following. Unless
     otherwise stated, the value returned by a command is that of the last
     simple-command executed in the command.

And whereas the POSIX base specifications include

       It should be noted that implementations will have different kinds of extensions. Some will reflect
        “historical usage” and will be preserved for execution of pre-existing applications. These functions
        should be considered “obsolescent” and the standard functions used for new applications.

the fact that many current shells (still) support the original function syntax are worth to the noted.
Desired Action Insert the following sentence at the given location:

Whereas historically the argument of shell functions (see xref 2.9.5, Function Definition Command) has been any command related shell construct, including [xref 2.9.1] simple commands, [xref 2.9.2] pipelines and [xref 2.9.3] lists, the POSIX standard shell only supports [xref 2.9.4] compound commands.
Tags tc3-2008
Attached Files

- Relationships

-  Notes
(0003994)
joerg (reporter)
2018-04-24 09:07

name () { list;} Define a function which is refer-
                                enced by name. The body of the
                                function is the list of commands
                                between { and }. The { must be
                                followed by a space. Execution of
                                functions is described below (see
                                Execution section). The { and }
                                are unnecessary if the body of
                                the function is a command as
                                defined above, under Commands.

Is in the AT&T sh manpage.

But the text in the POSIX standard is not related to that but rather to the ksh function definition:

      function identifier { list ;}
         Define a function which is referenced by identifier. The
         body of the function is the list of commands between {
         and }. See Functions.


Since the POSIX text mentions only the version with a compound statement, I see no reason for a need to add more hints.
(0004281)
geoffclare (manager)
2019-03-07 17:19

On page 3745 line 128574 section C.2.9.5, add a new paragraph:
Some shells accept non-compound commands after <tt>fname()</tt>, including simple commands (see [xref 2.9.1]), pipelines (see [xref 2.9.2]) and lists (see [xref 2.9.3]); however this standard only requires support for compound commands (see [xref 2.9.4]).
(0004287)
stephane (reporter)
2019-03-07 20:25

For the record, as pointed out by IIRC kre some time ago, the reason why POSIX didn't specify function definitions as

    funcname() any-command

was probably because

    funcname() simple-command > redir

didn't work in the Bourne shell or ksh88 (funcname() simple-command without redirections works in all shells except bash, yash and posh).

Re: Note: 0003994

However I don't thing suggesting some shells accept pipelines or lists as function body make sense.

    funcname() { x; } | y

And

    funcname() { x; } || y

are specified and POSIX doesn't allow those { x; } | y or { x; } || y to be taken as the body of the function and I don't think any shell ever did (whereas funcname() x is unspecified so implementations are allows to make x the body of the function).

IMO, the spec is currently fine as it is. I don't see the value in mentioning what some shells do as extensions, unless it's about giving a "future direction" mandating shells support funcname() simple-command.
(0004304)
geoffclare (manager)
2019-03-11 15:29

On page 3745 line 128574 section C.2.9.5, add a new paragraph:
Some shells accept simple commands (see [xref 2.9.1]) after <tt>fname()</tt> in addition to compound commands (see [xref 2.9.4]); however this standard only requires support for compound commands.

- Issue History
Date Modified Username Field Change
2018-04-23 18:10 steffen New Issue
2018-04-23 18:10 steffen Name => steffen
2018-04-23 18:10 steffen Section => vol. 3: sh
2018-04-23 18:10 steffen Page Number => 3239
2018-04-23 18:10 steffen Line Number => 108848
2018-04-24 09:07 joerg Note Added: 0003994
2019-03-07 17:19 geoffclare Note Added: 0004281
2019-03-07 17:20 geoffclare Interp Status => ---
2019-03-07 17:20 geoffclare Final Accepted Text => Note: 0004281
2019-03-07 17:20 geoffclare Status New => Resolved
2019-03-07 17:20 geoffclare Resolution Open => Accepted As Marked
2019-03-07 17:20 geoffclare Tag Attached: tc3-2008
2019-03-07 20:25 stephane Note Added: 0004287
2019-03-11 15:29 geoffclare Note Added: 0004304
2019-03-11 15:29 geoffclare Final Accepted Text Note: 0004281 => Note: 0004304
2019-11-08 11:51 geoffclare Status Resolved => Applied


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker