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


Groups > gnu.bash.bug > #13747

Function definitions

From moosotc@gmail.com
Newsgroups gnu.bash.bug
Subject Function definitions
Date 2018-02-26 13:45 +0300
Message-ID <mailman.9748.1519654113.27995.bug-bash@gnu.org> (permalink)

Show all headers | View raw


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:moosotc@gmail.com

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


Thread

Function definitions moosotc@gmail.com - 2018-02-26 13:45 +0300

csiph-web