-
Notifications
You must be signed in to change notification settings - Fork 7.2k
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
Add operator to create a thread job from a command #9873
Comments
@KirkMunro As I mentioned in the other issue, the handling of a trailing & is by design and matches Unix shell behaviour. As far as simple dispatch on a runspace or runspace pool, I always figured we'd do it with & $runspacePool invoke-stuff -arg1 -arg2 abc You do have to create the runspace or pool but that's not a huge deal. |
I see, so more like using the call operator with some thing where you want to run commands, like you can do with modules today (i.e. Without thinking too hard about it, right now I like the simplicity of something like the |
Do you think thread job usage will be great enough to warrant dedicated syntax?
But you can do this today without a dedicated operator: To me, the primary advantage of |
@rkeithhill I don't have usage data to answer that question. My argument for this functionality comes more from some of the core tenets of PowerShell: consistency and discoverability. I understand how |
Speaking of consistency, @BrucePay, there are several inconsistencies between the
|
As a result, if the character sequence isn't part of the defined exceptions and isn't able to be parsed as a regular variable name, they're treated like other bareword tokens and PS attempts to find command names that match as with all other generic bareword tokens. But yeah, that would be pretty useful. Wouldn't take a lot to add an extra special variable, just an extra tokenizer case and follow the trail the other special variables have laid out there. |
Great suggestion, @KirkMunro: Given that the postpositional
I wouldn't think about current usage with respect to thread jobs, because I think that thread jobs merely have a PR problem / in-box-availability problem (in older PS versions): If everyone knew that for most use cases they are functionally equivalent to child-process-based background jobs yet perform significantly better - while seamlessly integrating with the other |
I like this suggestion and would love to see it added sooner rather than later if this could be prioritised @SteveL-MSFT |
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. |
2 similar comments
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. |
Summary of the new feature/enhancement
As a scripter,
I want an operator that allows me to create a thread job from a single command
so that I can run commands on threads more easily in PowerShell.
This request is similar to the need for the recently added "ampersand background operator" (
&
) that allows you to run a command in a background job, but instead of running a command in a separate process, this operator would run the command in a separate thread.To differentiate this way of running commands from background jobs, a different sigil would be used for the operator at the end of a command. The sigil that is chosen must be something that the parser currently does not support so that it wouldn't break existing scripts.
Proposed technical implementation details (optional)
To be consistent with the existing ampersand background operator, a sigil of
&~
could be used. This sigil results in parser errors in versions of PowerShell that don't support the ampersand background operator.In PowerShell 6.2, it results in a command not found error, because PowerShell runs everything in the statement up to & as a background job and then looks to run everything after that operator as a subsequent command. Technically this means it would be a breaking change for anyone with a command called
~
, but only if they invoke that command immediately following a&
operator in a script.At any rate, here is what invocation might look like with a new glyph:
The text was updated successfully, but these errors were encountered: