[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: declare -f changes 'elif' to 'else if'
From: |
Chet Ramey |
Subject: |
Re: declare -f changes 'elif' to 'else if' |
Date: |
Mon, 21 Feb 2022 10:57:17 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 |
On 2/21/22 9:27 AM, sukolyn via wrote:
hi,
here's the picture :
$ 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)
What does this mean? `elif' is just syntactic sugar for `else if'; they are
equivalent internally. There's no reason to have a special parse tree
representation for `elif', so when the internal parse tree gets converted
back to an external form, you get `else if'.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/