Skip to content

function body parsing incomplete #7

@sunshineco

Description

@sunshineco

POSIX states that a function body is a compound command. This means that, among others, the following are legal (and widely supported):

% foo() { echo hello; }
% foo
hello

% bar() ( echo hello )
% bar
hello

% xyzzy() if true; then echo wizard; else echo muggle; fi
% xyzzy
wizard

% frobnitz() for i in $(seq 3); do echo $i; done
% frobnitz
1
2
3

Some shells also accept a simple command (in addition to compound) as the body. For instance, in dash and zsh:

% baz() echo hello
% baz
hello

However, flash's Parser::parse_function_definition() is too restrictive and only accepts a function body if wrapped in curly braces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions