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

Change positional parameter for powershell.exe from -Command to -File by SteveL-MSFT · Pull Request #4019 · PowerShell/PowerShell · GitHub

Change positional parameter for powershell.exe from -Command to -File - #4019

Merged
Dongbo Wang (daxian-dbw) merged 3 commits into
PowerShell:masterfrom
SteveL-MSFT:powershell-file-arg
Jun 19, 2017
Merged

Change positional parameter for powershell.exe from -Command to -File#4019
Dongbo Wang (daxian-dbw) merged 3 commits into
PowerShell:masterfrom
SteveL-MSFT:powershell-file-arg

Conversation

Copy link
Copy Markdown
Member

Previously powershell.exe treated unknown arguments as a command line to execute. To align with POSIX so that things like shebang scripts work correctly, we are changing powershell.exe so that it treats unknown arguments (aka positional argument) as a file. This means that powershell foo will now attempt to use foo as a PowerShell script whereas previously foo would be treated as a command to execute. This doesn't affect existing usage of either -File nor -Command. Fixed tests that didn't explicitly use -Command parameter.

Note that some of the changes below for trailing whitespace was due to VSCode setting.

Fix #1103
Fix #3959

Keith Hill (rkeithhill) commented Jun 15, 2017
edited
Loading

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT) You might find limiting that settting to just PowerShell files to be handy - especially for this repo e.g.:

    "[powershell]": {
        "files.trimTrailingWhitespace": true
    },

Then VSCode will not mess with trailing whitespace on .cs and .resx files.

Copy link
Copy Markdown
Contributor

You probably should fix the resx file to only include your intended change - the other whitespace changes do have a visible effect in the binary, which is probably fine, but should be in a different commit.


In reply to: 308830296 [](ancestors = 308830296)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Does this set the exit code correctly? You don't have a test - you should add one as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Will add test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

C# now supports local functions - that would make this a bit simpler because you wouldn't the parameters.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Making ParseFile a local function would make it inconsistent with similar methods like ParseCommand(), ParseFormat(), ParseExecutionPolicy(), etc...

Copy link
Copy Markdown
Contributor

Isn't this a breaking change? It should be documented in the release notes.

Jason Shirk (lzybkr) added the Breaking-Change breaking change that may affect users label Jun 16, 2017
… to execute. To align with POSIX so that things like shebang

scripts work correctly, we are changing powershell.exe so that it treats unknown arguments (aka positional argument) as a file.
This means that `powershell foo` will now attempt to use `foo` as a PowerShell script whereas previously `foo` would be treated
as a command to execute.  This doesn't affect existing usage of either `-File` nor `-Command`.  Fixed tests that didn't explicitly
use `-Command` parameter.
added test to validate exit code from script

Copy link
Copy Markdown
Member Author

Jason Shirk (@lzybkr) any other feedback, would like to get this into beta.3 since it's a breaking change and get the feedback

Dongbo Wang (daxian-dbw) merged commit 41f65de into PowerShell:master Jun 19, 2017
Steve Lee (SteveL-MSFT) deleted the powershell-file-arg branch June 19, 2017 21:16
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
…PowerShell#4019)

Previously powershell.exe treated unknown arguments as a command line to execute. To align with POSIX so that things like shebang scripts work correctly, we are changing powershell.exe so that it treats unknown arguments (aka positional argument) as a file. This means that `powershell foo` will now attempt to use `foo` as a PowerShell script whereas previously `foo` would be treated as a command to execute. This doesn't affect existing usage of either -File nor -Command. Fixed tests that didn't explicitly use -Command parameter.
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

Breaking-Change breaking change that may affect users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants


Back | FazBrowse Home | New Git URL