PowerShell Core is a cross-platform, so it makes sense to add support for operating system check to the #requires statement in case you want to write an OS-specific script.
Hum!! I'm using the isXXXX variables to identify which OS I want the code to execute. It won't hurt to implement another #REQUIRES -OS option.
:)
Benefit of #requires is that it's a parse time check and not runtime if the entire script is not compatible vs using $isWindows, etc...
I'm writing an RFC right to discuss platform differences. For the time being, I think it's a perfectly usable workaround to throw at the beginning of a psm1 if !isLinux.
Reminder here to discuss with @PowerShell/powershell-committee the possibility of pushing this out. No immediate need (certainly not moreso than the "interop" variables), and this should be done with intent.
@PowerShell/powershell-committee reviewed this and agree that this isn't needed for 6.0.0, we'll revisit the necessity at all post 6.0.0
I've opened an RFC on updating the behaviour of #requires. Please feel free to comment in the PR.
@joeyaiello Can this enhancement be included with PS 7?
This has been accepted in https://github.com/PowerShell/PowerShell-RFC/pull/122
Now it just needs to be implemented
I think we would be great to have a meta issue with not implemented RFCs.
I think we would be great to have a meta issue with not implemented RFCs.
We should discuss with @SteveL-MSFT and @joeyaiello, but I do keep feeling that RFCs don't integrate well with issue tracking for us.
I think meta issues tend to get neglected and aren't very helpful compared to a 1-issue-per-workitem approach and tagging. So my suggestion would be:
In the case we need one issue in RFC repo to track implementing and there can be some related issues and PRs in the repo.
Perhaps instead of a meta issue that itself is additional work to maintain, we should have a RFC Approved, Waiting on Implementation type label (but shorter) in this repo and have the ability to render a view of RFCs based on filtering criteria (we already need it for other purposes).
In the case we need to create an issue to apply the label.
Most helpful comment
I've opened an RFC on updating the behaviour of
#requires. Please feel free to comment in the PR.