I'm trying to make a PowerShell string to compile a program and if it's correctly compiled, I want to open the the program. The problem that I'm trying to solve is to understand how PowerShell understands when the MiniGW compiler with gcc command (for C files) throws a correct result.
Knowing that == TRUE and == FALSE are not accepted in PowerShell I tried an if without any logical operator
if(gcc '.\FileINeedToCompile.c'){
Write-Host Correct;
} else {
Write-Host NotCorrect;
}
but I get the NotCorrect result in the case that the program is correctly compiled and also the case it's not compiled.
I've also tried some varietions with the logical operator -eq like
if((gcc '.\FileINeedToCompile.c') -eq $FALSE)
but I get always the result of the else statement.
I searched everywhere and I really don't know how I could make this working. Thanks for help.
gccreturn on a successful compilation?gcc '.\FileINeedToCompile.c'? You can check the object type with(gcc '.\FileINeedToCompile.c').getType(). I would speculate that it is a string, so tryif((gcc '.\FileINeedToCompile.c') -eq "False")makeinstead of trying to roll your own build system.