Execute the conditions of if and while statements outside of their block

Variables set in if and while conditions are in the enclosing block, not
the if/while statement block. For example:

    if set -l var (somecommand) ; end
    echo $var

will now work as expected.

Fixes #4820. Fixes #1212.
This commit is contained in:
ridiculousfish
2018-03-31 14:57:24 -07:00
parent ba06a89923
commit 4b079e16e5
9 changed files with 90 additions and 36 deletions

View File

@@ -39,3 +39,13 @@ if false ; or true | false ; echo "failure5" ; end
logmsg Catch this corner case, which should produce an error
if false ; or --help ; end
logmsg Loop control in conditions
for i in 1 2 3
while break; end
echo $i
end
for i in 1 2 3
while continue; end
echo $i
end