Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upPropagate execution preferences beyond script module scope #221
Conversation
KevinMarquette
commented
Feb 29, 2020
|
I am surprised that this has been broken for as long as hit has. I find that this issue makes The real danger is most people don't realize it works this way. |
|
Agreed. This issue renders every common parameter effectively unusable for script module authors whenever they call commands external to their modules because most authors will not understand why some commands work without issue and others completely ignore the requested preference. I can only hope we can get it approved for a fix as soon as possible. |
bergmeister
commented
Mar 6, 2020
•
|
Stumbled across this today as well when I refactored code into a common script module where as a result of that the |
|
@joeyaiello @SteveL-MSFT is this one one your guys' radar at all? |
bwright86
commented
Jun 24, 2020
|
I am following the rabbit trail from Powershell\Powershell#4568, and am trying to solve this as well. I see DWyatt's "Get-CallerPreference" script, and am thinking of using something similar for now. There is an edge case to this proposal that may need considering. I have a module with a cmdlet(Adv. Function), that contains verbose messages to call out information, and is called by other higher-level cmdlets a lot of times (possibly hundreds of times). When I do IMO, I think opting-out of passing these preferences would be useful. But by default, I would like to see "Calling cmdlets" pass their preferences onto the "Called cmdlets". Mostly, because there isn't a preferred/documented/best-practice way to make this work currently. |
|
@bwright86 I can see that potentially being useful, but I think at least as an initial implementation it would be preferable that it affect everything; as you note, those authors can selectively pick and choose which cmdlets' preference variables are passed along by simply manually overriding the -Verbose (etc) params when their function calls other functions. I'm not sure a completely separate preference is necessary, but if it does end up being desirable I could see potentially something like an additional property in |
bwright86
commented
Jun 24, 2020
|
I agree with you, and I think what is being pointed out by this RFC and many SO questions, is that there isn't a good way to code the preferred way. So if this RFC goes forward, it would be nice to document the "opt-out" way for the use case i mentioned. So I wasn't looking for anything to be implemented from my edge case, but maybe something to keep in mind, or integrate into the RFC language. I think manually overriding the preference like you mentioned may be a good way around it, and calling it out in the As a side note, the issue I was facing today that caused me to go down this rabbit hole, was the |
KirkMunro commentedAug 16, 2019
This RFC was originally proposed as part of a collection of RFCs in PR #187. I am separating those RFCs into separate PRs to better adhere to the RFC process.