salt/pkg/windows/modules/start-process-and-test-exitcode.psm1
Elias Probst 34fb50b134
Fix typos (the the > the) (#52711)
* Fix typos (`the the` > `the`)

It looks like humans aren't only very bad at recognizing a double `the` in a sentence when reading [1], but they're also very good at sneaking them in unintentionally without noticing.

Fix this by running:
```
ack --ignore-dir=doc/man --ignore-dir=doc/topics/releases -i 'the the\W' -l | xargs sed -i 's|the the\(\W\)|the\1|g'
```

[1] Eye movements and word skipping during reading: Effects of word length and predictability: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3543826/

* Blacken changed files

* Blacken changed files

* Re-add unintentional delete

* Bad merge fix

* Fix broken docstring

* Another try

* pre-commit should pass now?

Co-authored-by: Daniel A. Wozniak <dwozniak@saltstack.com>
Co-authored-by: Wayne Werner <wwerner@saltstack.com>
2020-04-28 10:02:41 -07:00

26 lines
857 B
PowerShell

Function Start_Process_and_test_exitcode {
# This function is a wrapper for Start-Process that checks the exitcode
# It receives 3 parameters:
# $fun - the process that shall be started
# $args - the arguments of $fun
# $descr - the short description shown in the case of an error
Param(
[Parameter(Mandatory=$true)] [String] $fun,
[Parameter(Mandatory=$true)] [String] $args,
[Parameter(Mandatory=$true)] [String] $descr
)
Begin { Write-Host "Executing Command: $fun $args" }
Process {
$p = Start-Process "$fun" -ArgumentList "$args" -Wait -NoNewWindow -PassThru
If ($p.ExitCode -ne 0) {
Write-Error "$descr returned exitcode $p.ExitCode."
exit $p.ExitCode
}
}
End { Write-Host "Finished Executing Command: $fun $args" }
}