[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: declare -f changes 'elif' to 'else if'
From: |
Greg Wooledge |
Subject: |
Re: declare -f changes 'elif' to 'else if' |
Date: |
Mon, 21 Feb 2022 09:40:20 -0500 |
On Mon, Feb 21, 2022 at 03:27:50PM +0100, sukolyn via wrote:
> $ myFunc() { if test foo; then : ; elif test bar; then : ; else : ; fi;}
>
> $ declare -f myFunc
>
> myFunc ()
> {
> if test foo; then
> :;
> else
> if test bar; then
> :;
> else
> :;
> fi;
> fi
> }
>
> `else' should be subordonate(?) to main `if' (i.e. `foo' command), not to
> inner if (`bar' command)
Well, they're both equivalent. So the transformation, while surprising,
isn't *wrong*.
I didn't know bash performed that transformation internally, but I can
see it as reasonable.