On 9/1/22 1:24 PM, Rob Landley wrote:

Hey Chet: why doesn't bash accept non-compound commands as functions? I have
wondered. Apparently other shells disagree on this...?

Because the POSIX grammar says a function body is a compound command,
optionally followed by a redirection list, and I never saw the need to
extend that.

function_definition : fname '(' ')' linebreak function_body
                 ;
function_body    : compound_command                /* Apply rule 9 */
                 | compound_command redirect_list  /* Apply rule 9 */
                 ;

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    [email protected]    http://tiswww.cwru.edu/~chet/

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to