Skip to content

Changed and() and or() to stop at the argument that decides the result - #6440

Draft
nickanderson wants to merge 1 commit into
cfengine:masterfrom
nickanderson:CFE-4272/master
Draft

nickanderson wants to merge 1 commit into
cfengine:masterfrom
nickanderson:CFE-4272/master

Conversation

@nickanderson

Copy link
Copy Markdown
Member

and() and or() now have delayed evaluation and expand their arguments
one at a time, from left to right. They return at the first false
(and()) or true (or()) argument, so function calls in the remaining
arguments are not made, like && and || in C or shell. A function that
would fail after the deciding argument no longer causes the whole call
to be skipped.

Handling of unresolved variables doesn't change: if any argument
(including nested function calls) has one, evaluation is skipped for
now. Only variables are expanded for this check, no functions are
called.

none() and reglist() now also stop at the first matching element, like
some() and regarray() already did. Their results don't change.

Ticket: CFE-4272
Ticket: CFE-4751
Changelog: Title

@nickanderson
nickanderson marked this pull request as draft October 26, 2026 13:09
and() and or() now have delayed evaluation and expand their arguments
one at a time, from left to right. They return at the first false
(and()) or true (or()) argument, so function calls in the remaining
arguments are not made, like && and || in C or shell. A function that
would fail after the deciding argument no longer causes the whole call
to be skipped.

Handling of unresolved variables doesn't change: if any argument
(including nested function calls) has one, evaluation is skipped for
now. Only variables are expanded for this check, no functions are
called.

none() and reglist() now also stop at the first matching element, like
some() and regarray() already did. Their results don't change.

Ticket: CFE-4272
Ticket: CFE-4751
Changelog: Title
@cf-bottom

Copy link
Copy Markdown

Thanks for submitting a PR! Maybe @craigcomstock can review this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants