I am trying to achieve a specific logic in PowerShell 1-liner that is similar to the following bash command:
{ $another_command_group ;} && { A ; { B && C ;} ;} && { $another_command_group ;}
{ A ; { B && C ;} ;}
The logic of this command is as follows:
- A=0, B=0, C=0, then it will execute nothing, and this Command Group will return a 0
- A=0, B=0, C=1, then it will execute nothing, and this Command Group will return a 0
- A=0, B=1, C=0, then it will execute Command B only, and this Command Group will return a 0
- A=0, B=1, C=1, then it will execute Command B and Command C, and this Command Group will return a 1
- A=1, B=0, C=0, then it will execute Command A only, and this Command Group will return a 0
- A=1, B=0, C=1, then it will execute Command A only, and this Command Group will return a 0
- A=1, B=1, C=0, then it will execute Command A and Command B, and this Command Group will return a 0
- A=1, B=1, C=1, then it will execute All Command A, B, C, and this Command Group will return a 1
PowerShell version: 7.26
OS: Windows
What I already tried:
( A ; ( B && C ) )
Not Working.
| Missing closing ')' in expression.
A ; ( B && C )
Worked though, but apparently this is not good enough, because I need the Parentheses
()
to make them a(group)
to stick with other(group)s
withAND &&
I am having trouble finding a one-liner Command to replicate this logic in PowerShell. I would greatly appreciate any suggestions or solutions.