sudo
sudo copied to clipboard
Add `--` instead of performing a short-circuit upon detecting a script-block.
Description of the new feature / enhancement
Enhance sudo to recognize and support script blocks prefixed with --. Currently, the script will short-circuit and execute script blocks directly, leading to perhaps unexpected behavior. By introducing support for the -- prefix, users can clearly indicate when a following argument is a script block.
Scenario when this would be used?
One scenario where adding support for the -- argument for script blocks would be useful is when users need to pass a script block as an argument to the sudo command within a command line environment.
With the -- argument implemented, users can specify script blocks explicitly, ensuring that they are processed correctly by sudo. This can be particularly useful in automation scenarios, scripting tasks, or when invoking sudo from other scripts or tools where passing script blocks as arguments is necessary. Call it free will if you may.
Supporting information
- Sudo Manual -> Sudo
Thanks for the feedback - I'm going to remove the needs triage label and keep the Issue-Feature tag.
Out of curiosity, do you have any specific examples that we can add to the issue here for tracking? I'm sure I can come up with some, but it'd be great if you have some examples we can use!
One scenario where this enhancement is valuable is in situations where users need to pass script blocks as arguments to sudo.
sudo -- ./script.ps1 --param1 value1 --param2 value2.