GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Implement -version parameter in console host (address part of https:/… by JamesWTruher · Pull Request #3115 · PowerShell/PowerShell

Conversation

@JamesWTruher

@JamesWTruher James Truher (JamesWTruher) commented Feb 8, 2017 •
edited by daxian-dbw
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

#1084

This does not support providing a specific version to run, but
like most other *nix commands, -version will now return the version
of the PowerShell Engine. 'powershell' is prepended to the output to
match other *nix commands. We are using gitcommitid which includes more
info about the build.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@msftclas Microsoft Contribution License Agreements (msftclas) added the cla-not-required label Feb 8, 2017
@PowerShellTeam PowerShellTeam added the Review - Needed The PR is being reviewed label Feb 8, 2017
@SteveL-MSFT Steve Lee (SteveL-MSFT) added the Review - Committee The PR/Issue needs a review from the PowerShell Committee label Feb 8, 2017
@joeyaiello Joey Aiello (joeyaiello) added Committee-Reviewed PS-Committee has reviewed this and made a decision and removed Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Feb 9, 2017
@joeyaiello

Joey Aiello (joeyaiello) commented Feb 9, 2017

Copy link
Copy Markdown
Contributor

@PowerShell/powershell-committee is good with all of this. 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vors
sergei (vors) reviewed Feb 9, 2017
View reviewed changes
Comment thread src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs Outdated

@vors sergei (vors) Feb 9, 2017 •
edited by JamesWTruher
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

redundant extra-line before else #Resolved

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs Outdated

@vors sergei (vors) Feb 9, 2017 •
edited by JamesWTruher
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

why not simple { get; private set; } #WontFix

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@daxian-dbw Dongbo Wang (daxian-dbw) Feb 9, 2017 •
edited by JamesWTruher
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think it's fine to follow the existing code pattern here. We can convert the style using a tool later. #ByDesign

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@JamesWTruher James Truher (JamesWTruher) Feb 17, 2017

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

to match the current code style


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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs Outdated

@vors sergei (vors) Feb 9, 2017 •
edited by JamesWTruher
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I wonder how it's going to interact with existing in Windows PowerShell
powershell -version 2.0

Since we are stopping to build Windows powershell, and core edition doesn't have any -version 2.0 support, it's probably okey. #ByDesign

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@SteveL-MSFT Steve Lee (SteveL-MSFT) Feb 9, 2017 •
edited by JamesWTruher
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

sergei (@vors), the @PowerShell/powershell-committee discussed this and that is pretty much the thinking: -version for Windows PowerShell really only supported 2.0 and we're moving away from that. Aligning with Linux convention makes sense. PSCore supports side-by-side intrinsically and using file paths to launch different versions is completely acceptable. #ByDesign

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@joeyaiello Joey Aiello (joeyaiello) Feb 9, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Furthermore we can always do something like powershell -version:2 if people really demand that functionality in the future (and actually Jason Shirk (@lzybkr) and Bruce Payette (@BrucePay) agreed that it would even be acceptable to do powershell -version 2 as it's highly unlikely that anyone wants to echo one int when they shell out to PowerShell).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
daxian-dbw
Dongbo Wang (daxian-dbw) requested changes Feb 9, 2017
View reviewed changes
Comment thread src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs Outdated

@daxian-dbw Dongbo Wang (daxian-dbw) Feb 9, 2017 •
edited by JamesWTruher
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Why are you setting _commandLineCommand here? #Resolved

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@JamesWTruher James Truher (JamesWTruher) Feb 17, 2017

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

vestige of earlier implementation - removed


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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs Outdated

@daxian-dbw Dongbo Wang (daxian-dbw) Feb 9, 2017 •
edited by JamesWTruher
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I recommend to use PSVersionInfo.GetPSVersionTable()["GitCommitId"], or even better, add an internal static property GitCommitId right after the PSVersion property at here, and then use PSVersionInfo.GitCommitId here.

Reason: PSVersionInfo has a type initializer, which calls GetCommitInfo() and store the value in a hashtable. the current implementation of GetCommitInfo() reads git commit information from a file, which is slow and this implementation is subject to change (this method may be gone in near future -- we want to generate code at build time to embed the git commit id info, so as to avoid reading a file at startup time). Since the type initializer must run the first time you access a type, it's a waste to call GetCommitInfo() here to read the file again. #Resolved

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/powershell/Host/ConsoleHost.Tests.ps1 Outdated

@daxian-dbw Dongbo Wang (daxian-dbw) Feb 9, 2017 •
edited by JamesWTruher
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

There is an extra blank line here. #Resolved

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/powershell/Host/ConsoleHost.Tests.ps1 Outdated

@daxian-dbw Dongbo Wang (daxian-dbw) Feb 9, 2017 •
edited by JamesWTruher
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

what would happen if I have powershell -noprofile -noexit -version? #WontFix

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@JamesWTruher James Truher (JamesWTruher) Feb 17, 2017

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

it would report the version and exit - I can add a test for that explicitly if you like. Rather than testing all of the permutations for the parameters, I chose a representative single case


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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@daxian-dbw Dongbo Wang (daxian-dbw) self-assigned this Feb 9, 2017
@daxian-dbw Dongbo Wang (daxian-dbw) added Review - Waiting on Author and removed Review - Needed The PR is being reviewed labels Feb 9, 2017
@JamesWTruher
Implement -version parameter in console host (address part of PowerSh…
9a608aa
…ell#1084)

This does not support providing a specific version to run, but
like most other *nix commands, -version will now return the version
of the PowerShell Engine. 'powershell' is prepended to the output to
match other *nix commands. We are using gitcommitid which includes more
info about the build.
@PowerShellTeam PowerShellTeam added Review - Needed The PR is being reviewed and removed Review - Waiting on Author labels Feb 17, 2017
@JamesWTruher
use a new static internal for GitCommitId rather than calling method …
96abb8f
…on PSVersionInfo

Remove extraneous blank lines in files
remove line which set the commandline when retrieving the version as it is unneeded
@JamesWTruher
James Truher (JamesWTruher) force-pushed the jameswtruher/ShowVersion branch from 39e0991 to 96abb8f Compare February 17, 2017 23:12
daxian-dbw
Dongbo Wang (daxian-dbw) approved these changes Feb 22, 2017
View reviewed changes

@daxian-dbw Dongbo Wang (daxian-dbw) left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 9e27f4a into PowerShell:master Feb 23, 2017
@iSazonov Ilya (iSazonov) removed the Review - Needed The PR is being reviewed label Mar 27, 2017
@SteveL-MSFT Steve Lee (SteveL-MSFT) mentioned this pull request Sep 14, 2017
powershell -version 2 should return error #4834
Closed
@JamesWTruher
James Truher (JamesWTruher) deleted the jameswtruher/ShowVersion branch September 23, 2023 05:33
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@JamesWTruher @daxian-dbw
Implement -version parameter in console host (address part of https:/… (
19213a2
PowerShell#3115)

* Implement -version parameter in console host (address part of PowerShell#1084)

This does not support providing a specific version to run, but
like most other *nix commands, -version will now return the version
of the PowerShell Engine. 'powershell' is prepended to the output to
match other *nix commands. We are using gitcommitid which includes more
info about the build.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@SteveL-MSFT Steve Lee (SteveL-MSFT) SteveL-MSFT left review comments
@daxian-dbw Dongbo Wang (daxian-dbw) daxian-dbw approved these changes
+2 more reviewers
@vors sergei (vors) vors left review comments
@joeyaiello Joey Aiello (joeyaiello) joeyaiello left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@daxian-dbw Dongbo Wang (daxian-dbw)

Labels

Committee-Reviewed PS-Committee has reviewed this and made a decision

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@JamesWTruher @joeyaiello @daxian-dbw @vors @SteveL-MSFT @PowerShellTeam @msftclas @iSazonov
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.