bug-bash
[Top][All Lists]
Advanced

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

Re: Function definitions


From: Pierre Gaston
Subject: Re: Function definitions
Date: Mon, 26 Feb 2018 16:16:26 +0200

On Mon, Feb 26, 2018 at 12:45 PM, <address@hidden> wrote:

>
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu'
> -DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
> -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib  -D_FORTIFY_SOURCE=2
> -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt
> -DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/bin'
> -DSTANDARD_UTILS_PATH='/usr/bin' -DSYS_BASHRC='/etc/bash.bashrc'
> -DSYS_BASH_LOGOUT='/etc/bash.bash_logout' -DNON_INTERACTIVE_LOGIN_SHELLS
> -Wno-parentheses -Wno-format-security
> uname output: Linux linmac2 4.15.5-1-ARCH #1 SMP PREEMPT Thu Feb 22
> 22:15:20 UTC 2018 x86_64 GNU/Linux
> Machine Type: x86_64-unknown-linux-gnu
>
> 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'
>
> # 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:address@hidden
>
>
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


reply via email to

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