[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unexpected parse error in function definition involing grouping brac
From: |
Michael Le Barbier Grünewald |
Subject: |
Re: Unexpected parse error in function definition involing grouping braces and redirections |
Date: |
Tue, 16 Jun 2015 15:17:04 +0200 |
Hi Greg,
thank you for your answer!
> On 16 Jun 2015, at 14:58, Greg Wooledge <wooledg@eeg.ccf.org> wrote:
>
> On Tue, Jun 16, 2015 at 01:56:31PM +0200, Michael Le Barbier Grünewald wrote:
>> 1>&2 {
>> printf "$@"
>> printf '\n'
>> }
>
> Redirections may appear anywhere in a simple command, but may only appear
> at the END of a compound command. Brace grouping is a compound command,
> so this is actually a syntax error.
I was not aware of this, and this is actually described in the REDIRECTIONS
paragraph of the manual page.
Nevertheless, when evaluating the second snippet
failwith()
{
1>&2 {
printf 'Failure: '
printf "$@"
printf '\n'
}
exit 1
}
bash does not report the syntax error and resumes interpretation, so that
as far as I understand, there is something to investigate here.
Best regards,
Michael