Skip to content

Commit abf9334

Browse files
author
Sean Wheeler
committed
Merge branch 'pipeline-chain-operators' of https://github.com/rjmholt/PowerShell-Docs into pipeline-chain-operators
2 parents bdccbbe + 118a564 commit abf9334

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

reference/7/Microsoft.PowerShell.Core/About/about_Pipeline_Chain_Operators.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ npm run build && npm run deploy
3434
The `&&` operator will execute the right-hand pipeline,
3535
if the left-hand pipeline succeeded,
3636
whereas the `||` operator will execute the right-hand pipeline
37-
if the left-hand pipeline failed:
37+
if the left-hand pipeline failed.
38+
39+
#### Two successful commands
3840

3941
```powershell
4042
Write-Output 'First' && Write-Output 'Second'
@@ -45,6 +47,8 @@ First
4547
Second
4648
```
4749

50+
#### First command fails, causing second not to be executed
51+
4852
```powershell
4953
Write-Error 'Bad' && Write-Output 'Second'
5054
```
@@ -55,6 +59,8 @@ Write-Error 'Bad' && Write-Output 'Second' : Bad
5559
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException
5660
```
5761

62+
#### First command succeeds, so `||` means second command not executed
63+
5864
```powershell
5965
Write-Output 'First' || Write-Output 'Second'
6066
```
@@ -63,6 +69,8 @@ Write-Output 'First' || Write-Output 'Second'
6369
First
6470
```
6571

72+
#### First command fails, so `||` means second command is executed
73+
6674
```powershell
6775
Write-Error 'Bad' || Write-Output 'Second'
6876
```

0 commit comments

Comments
 (0)