How to invoke command if multiple previous commands execute successfully? #21330
-
I'm currently performing: sudo zypper dup && `
flatpak update -y && `
flatpak uninstall --unused && `
sudo snap refresh && `
Stop-Computer I'd like to solely invoke Specifically, I'm probably going the wrong way about doing this. Maybe I should just be using a function which is called before |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
You could use jobs to do this, each job will run but the final statement will only run if none had an error
Will produce
If you uncomment the Write-Error you get
|
Beta Was this translation helpful? Give feedback.
-
Given you are running external programs and have to check the $LastExitCode to detect an error then sum up the $LastExitcCde, it it is zero then there were no errors
Change any of the /usr/bin/true to /usr/bin/false to see the effect |
Beta Was this translation helpful? Give feedback.
Given you are running external programs and have to check the $LastExitCode to detect an error then sum up the $LastExitcCde, it it is zero then there were no errors
Change any of the /usr/bin/true to /usr/bin/false to see the ef…