mardi 6 août 2019

Why my condition (-not A -and (A -or B -or C)) doesn't work?

I wrote _in function to detect if we must install packages or not. The arguments -packages and +packages work but +base and +full don't work, how can I fix it ?

$scriptArgs=$args

function _in {
  param ($find)
  foreach ($i in $scriptArgs) {
    if ($i -eq $find) {
      Return 1
    }
  }
  Return 0
}

# Install packages
if (-not (_in("-packages")) -and (_in("+packages") -or _in("+base") -or _in("+full"))) {
  PrintInfo "* Installing packages"
}

Work :

$ powershell .\scripts\win\install_zds.ps1 +packages
* Installing packages
$ powershell .\scripts\win\install_zds.ps1 +packages -packages

-packages disable package installation. and -packages enable package installation.

Doesn't work :

$ powershell .\scripts\win\install_zds.ps1 +base
$ powershell .\scripts\win\install_zds.ps1 +full

+base and +full should enable package installation.

Aucun commentaire:

Enregistrer un commentaire