[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Function definitions
From: |
moosotc |
Subject: |
Re: Function definitions |
Date: |
Mon, 26 Feb 2018 18:24:11 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Chet Ramey <chet.ramey@case.edu> writes:
> On 2/26/18 5:45 AM, moosotc@gmail.com 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.
Thank you for an explanation. My takeaway is that most, if not all,
[kaz]sh descendants[1] allow something that IEEE Std 1003.1-2008, 2016
Edition doesn't.
[1] dash,busybox,mksh,zsh
--
mailto:moosotc@gmail.com