microsoft / microsoft/sudo

Unify command execution in sudo.ps1

Open
#46 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Task
Dominant language
Rust
Stars
5.9k
Forks
180
Avg merge
1d 7h
Merged PRs (30d)
2

Description

Description of the new feature / enhancement

There are 3 places in the sudo.ps1 script that execute SUDOEXE in the following manner:

if (($psversiontable.psversion.major -eq 7) -and ($__SUDO_DEBUG -eq $true)) {
	Trace-Command -PSHOST -name param* -Expression { & $SUDOEXE ... }
}
else {
	& $SUDOEXE ...
}

Maybe export this logic to a function Run-Sudo or something along those lines?

Scenario when this would be used?

Any future change, bugfix, or improvement to the sudo executable or sudo script that need to be addressed at the points of command execution will only need to be applied in 1 place.

Supporting information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in sudo.ps1 and locate the three repeated SUDOEXE execution blocks. Compare their PowerShell 7 debug and normal paths, then centralize that behavior in one helper and replace all three call sites while preserving the existing execution behavior. Done means future command-execution changes can be made in one place.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.