New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Harmonize Get-Process and Stop-Process syntax with Wait-Process to accept both ID and name positionally #6551
Comments
|
Yes, but sometimes you want to kill all process instances of a given executable or you may happen to know that there's only one. If someone uses, say, Personally, I would value the convenience of, say, Yes, the change would be a breaking one, but the risks strike me as low. |
@mklement0 The pattern for stopping multiple processes is:
As a general rule, while designing PowerShell, we tried to avoid making it too convenient to accidently perform destructive operations. "Convenience and consistency" that make it easier to do the wrong thing are not desirable. |
Yes, that pattern is easier than Here's another pattern, which is the one that keeps tripping me up:
Preventing accidental destruction is a good thing to strive for, but it seems to me the better way to handle this is via confirmation prompts / (Both features already are a part of Also note that the the current restriction offers little protection: If I try to use As an aside: the error message you get for
|
After a 3-step process (including looking up the command syntax), one hopes one is paying attention to what one is doing. In summary, providing friction along destructive paths doesn't guarantee that you won't do something unwise, but it gives you more opportunities to think about what you are doing. |
I fully agree: sowing confusion with inconsistency and unhelpful error messages, and generally making the task at hand as difficult as possible even to those who know what they're doing is indeed the best way to educate and guide users toward not harming themselves. Satire aside, is this not a fair summary of the current behavior? |
See #2722 for a related discussion. |
Thanks, @lzybkr. Note that This behavior makes sense to me (it is easily explained and easy to remember), and while it is obviously less dangerous in Returning to (also) defaulting to Here's the very first example from Example 1: Stop all instances of a process
This command stops all instances of the Notepad process on the computer. This tells me two things:
So, if This not being the case amounts to nothing but a puzzling inconvenience; it is not educational, and not recognizable as a safety measure. In fact, until @BrucePay framed it as a safety feature, that had never even crossed my mind - despite my knowing of the implications (potentially killing multiple processes). |
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
1 similar comment
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes. |
Note: Technically, this would be a Bucket 3: Unlikely Grey Area change.
Wait-Process
conveniently allows you to target a process by positional argument either by Name or by ID; that is, if a process namedfoo
exists withId
(PID)1
, you can choose either of the following options:This is convenient; in the unlikely event of an all-digits process name, you can use
-Name
to disambiguate.Note: since
-Name
and-Id
are array-valued, the-Id
parameter is only bound if all array elements can be parsed as[int]
.By contrast,
Get-Process
andStop-Process
:do not offer the same convenience
bind to different parameters by default:
Get-Process
binds the 1st positional argument to-Name
,Stop-Process
to-Id
.Harmonizing the parameter syntax among all 3 cmdlets:
provides more convenience overall
lessens the cognitive load of having to remember which cmdlets defaults to what parameter.
Hypothetically, existing scripts that used something like
Get-Process 1234
could break, because with the new syntax the previously-Name
-bound1234
value would now bind to-Id
- again, this would only apply to an all-digits name that can be parsed as (and fit into) an[int]
.Environment data
Written as of:
PowerShell Core v6.0.2
The text was updated successfully, but these errors were encountered: