@@ -14,6 +14,10 @@ Describes chaining pipelines with the `&&` and `||` operators in PowerShell.
14
14
15
15
## Long description
16
16
17
+ > [ !NOTE]
18
+ > This is an experimental feature. For more information see
19
+ > [ about_Experimental_Features] ( about_Experimental_Features.md ) .
20
+
17
21
Beginning in PowerShell 7, PowerShell implements the ` && ` and ` || ` operators to
18
22
conditionally chain pipelines. These operators are known in PowerShell as
19
23
* pipeline chain operators* , and are similar to
@@ -26,7 +30,10 @@ The `&&` operator executes the right-hand pipeline, if the left-hand pipeline
26
30
succeeded. Conversely, the ` || ` operator executes the right-hand pipeline if
27
31
the left-hand pipeline failed.
28
32
29
- This can be use for conditional execution of software deployments. For example:
33
+ These operators use the ` $? ` and ` $LASTEXITCODE ` variable to determine if a
34
+ pipeline failed. This allows you to use them with native command and not just
35
+ with cmdlets or functions. This can be use for conditional execution of
36
+ software deployments. For example:
30
37
31
38
``` powershell
32
39
npm run build && npm run deploy
@@ -35,10 +42,6 @@ npm run build && npm run deploy
35
42
In this example the ` npm run deploy ` command only runs if the build command
36
43
succeeds.
37
44
38
- > [ !NOTE]
39
- > This is an experimental feature. For more information see
40
- > [ about_Experimental_Features] ( about_Experimental_Features.md ) .
41
-
42
45
### Examples
43
46
44
47
#### Two successful commands
0 commit comments