FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Pipeline chain operators by rjmholt · Pull Request #9849 · PowerShell/PowerShell · GitHub

Pipeline chain operators - #9849

Merged
Dongbo Wang (daxian-dbw) merged 42 commits into
PowerShell:masterfrom
rjmholt:bash-operators
Oct 17, 2019
Merged

Pipeline chain operators#9849
Dongbo Wang (daxian-dbw) merged 42 commits into
PowerShell:masterfrom
rjmholt:bash-operators

Conversation

Rob Holt (rjmholt) commented Jun 7, 2019
edited
Loading

Copy link
Copy Markdown
Collaborator

This PR is specified by PowerShell/PowerShell-RFC#192

PR Summary

Resolves #3241.

Implements && and ||.

A statement like cmd1 && cmd2 should behave like cmd1; if ($?) { cmd2 }.

After discussion with the @PowerShell/powershell-committee, this feature has the following charateristics:

  • cmd1 && cmd2 behaves like cmd1; if ($?) { cmd2 }
  • cmd1 || cmd2 behaves like cmd1; if (-not $?) { cmd2 }
  • cmd1 && cmd2 && cmd3 is left associative: [cmd1 && cmd2] && cmd3
  • No control flow statements in pipeline chains; only pipelines. Control flow statements are still possible with subexpressions in pipelines (cmd1 && $(break)). These were taken out due to the inconsitencies they posed at a grammatical, data structure and semantic level.
  • Assignment is consistent with other assignment in PowerShell, so that a script terminating error will not result in a partial assignment, but a pipeline-terminating error will.
  • This syntax is available as the PSPipelineChainOperators experimental feature

PR Checklist

Dongbo Wang (daxian-dbw) commented Jun 11, 2019
edited
Loading

Copy link
Copy Markdown
Member

The && and || operators allow statements for both operands in bash. Why don't we do the same in PowerShell?

Copy link
Copy Markdown
Collaborator Author

Discussed this offline with Dongbo Wang (@daxian-dbw). We've decided to get rid of the subordinate statements and move assignment up to the whole chain (so no $x = cmd1 && $y = cmd2). I'll try to rework this today or tomorrow

Copy link
Copy Markdown

Rob Holt (@rjmholt) Can you explain the reasoning in this PR thread?

Copy link
Copy Markdown
Collaborator Author

Can you explain the reasoning in this PR thread?

I've discussed again with Dongbo Wang (@daxian-dbw) and we agreed this is now best served by an RFC. When that RFC is accepted, I'll make the desired changes in this branch

Copy link
Copy Markdown
Collaborator Author

Please see PowerShell/PowerShell-RFC#192

Copy link
Copy Markdown

Excellent, thanks

Comment thread build.psm1
Comment thread build.psm1
Comment thread build.psm1
Dongbo Wang (daxian-dbw) merged commit 2a518fc into PowerShell:master Oct 17, 2019
Dongbo Wang (daxian-dbw) added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Oct 17, 2019

Copy link
Copy Markdown
Collaborator Author

🎉

Copy link
Copy Markdown
Member

🎉🎉🎉 Nice!

Copy link
Copy Markdown

This is awesome! Looking forward to having a look in PS7 preview 5!

Andrew (anmenaga) changed the title Pipeline chain operators (&&, ||) Pipeline chain operators Oct 22, 2019
Ben Boeckel (mathstuf) added a commit to mathstuf/tar-rs that referenced this pull request Oct 26, 2019
The `&&` syntax is not supported in PowerShell. See
PowerShell/PowerShell#9849.
Ben Boeckel (mathstuf) added a commit to mathstuf/tar-rs that referenced this pull request Oct 26, 2019
The `&&` syntax is not supported in PowerShell (yet). See
PowerShell/PowerShell#9849.
Ryan Yates (kilasuit) pushed a commit to kilasuit/PowerShell that referenced this pull request Nov 9, 2019
bb010g (bb010g) added a commit to bb010g/dein.vim that referenced this pull request Dec 6, 2019
bb010g (bb010g) added a commit to bb010g/dein.vim that referenced this pull request Dec 6, 2019
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log

Projects

None yet

Back | FazBrowse Home | New Git URL