Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #13753

Re: Function definitions

From moosotc@gmail.com
Newsgroups gnu.bash.bug
Subject Re: Function definitions
Date 2018-02-26 18:26 +0300
Message-ID <mailman.9755.1519658824.27995.bug-bash@gnu.org> (permalink)
References <877er0qbb7.fsf@gmail.com> <CAPSX3sQAtEFOn5TUTEpr=Ja0UQVj7p0yr=N6sGA=uJFjafCrtQ@mail.gmail.com>

Show all headers | View raw


Pierre Gaston <pierre.gaston@gmail.com> writes:

> On Mon, Feb 26, 2018 at 12:45 PM, <moosotc@gmail.com> wrote:
>
[..snip..]

>>
>> $ func() true
>> bash: syntax error near unexpected token `true'
>>
>> # Variant#2
>> $ func() { true }
>> > ^C
>>
>> Both forms seem to be valid per [1] and are accepted by (at least)
>> ash, zsh and mksh
>>
>> Worth noting that the Variant#2 can be made to work in bash with an
>> addition
>> of a semicolon:
>>
>> $ func() { true; }
>>
>> [1] http://pubs.opengroup.org/onlinepubs/9699919799/
>> utilities/V3_chap02.html
>>
>> --
>> mailto:moosotc@gmail.com
>>
>>
> On the contrary SUS doesn't define either one, as function definition
> requires a compound command
>
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_05
>
> and  it requires a delimiter in compound commands
>
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_04

Thanks.

-- 
mailto:moosotc@gmail.com

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Function definitions moosotc@gmail.com - 2018-02-26 18:26 +0300

csiph-web