in ,

Pipeline chain operators by rjmholt · Pull Request # 9849 · PowerShell / PowerShell, Hacker News

Pipeline chain operators by rjmholt · Pull Request # 9849 · PowerShell / PowerShell, Hacker News
          

This PR is specified by PowerShell / PowerShell-RFC #

Resolves # 192.

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 PR has a meaningful title Use the present tense and imperative mood when describing your changes.

    • Summarized changes
    • (Make sure all h , .cpp , . cs , . ps1 and . psm1 files have the correct copyright header
    • This PR is ready to merge and is not Work in Progress . If the PR is work in progress, please add the prefix WIP: or [ WIP ] to the beginning of the title (the bot will keep its status check at while the prefix is ​​present) and remove the prefix when the PR is ready. Breaking changes None) OR Experimental feature. (s) needed
    • Experimental feature name (s): PSPipelineChainOperators
    • User-facing changes
    • Not Applicable
    • OR Documentation needed

    • Issue filed: (MicrosoftDocs / PowerShell-Docs #)
    • Testing - New and feature N / A or can only be interactively

      (Read More

      ) Brave Browser

      What do you think?

      Leave a Reply

      Your email address will not be published. Required fields are marked *

      GIPHY App Key not set. Please check settings

      Dow Futures Crash as Deadly China Virus Threatens to Derail Economy, Crypto Coins News

      Dow Futures Crash as Deadly China Virus Threatens to Derail Economy, Crypto Coins News

      Join the Costrak Accounts beta, Hacker News

      Join the Costrak Accounts beta, Hacker News