withPrivileges abstract method
When a script is run under sudo on Linux and MacOS and you
have previously called releasePrivileges then this method
will run action
with root privileges.
If you attempt to call withPrivileges when not running
as a privileged process a ShellException will be thrown
unless the allowUnprivileged
flag is set.
Use isPrivilegedProcess to check if your script was started as a priviliged process.
Nesting withPrivileges blocks is allowed as a convenience.
You must NEVER call releasePrivileges within a withPrivileges action.
See:
Implementation
void withPrivileges(RunPrivileged action, {bool allowUnprivileged = false});