bug-bash
[Top][All Lists]
Advanced

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

Re: Function definitions


From: Chet Ramey
Subject: Re: Function definitions
Date: Mon, 26 Feb 2018 09:20:55 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 2/26/18 5:45 AM, address@hidden wrote:

> Bash Version: 4.4
> Patch Level: 19
> Release Status: release
> 
> Description:
>         Bash rejects valid function definitions
> 
> Repeat-By:
> 
> $ func() true
> bash: syntax error near unexpected token `true'

Yes, bash requires that function bodies be compound commands, as the Posix
grammar specifies.

> # Variant#2
> $ func() { true }
>> ^C

This is not a valid compound command. To be recognized as a reserved word,
and end the group command, the close brace must appear in a context where
a reserved word is valid. The argument to a simple command is not such a
place.

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



reply via email to

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