Skip to content

sudo

Run direct commands or block-scoped operations with elevated privileges via sudo.

Functions

run cmd :user? :cd? :env? ...args

Runs a verbatim command through sudo.

Parameters
Name type Description
cmd Program to run
user Str? Account to use instead of root
cd Path? Working directory requested via sudo
env Dict Environment requested via sudo policy
args * Arguments passed verbatim to cmd
Returns

nil

Example
sudo.run install -m 0644 example.conf /etc/example.conf

with func :user? :cd? :env?

Runs a block with elevated privileges through sudo.

Filesystem access and spawned programs use a temporary elevated VFS for the duration of the block. Pass user to run as an account other than root.

Parameters
Name type Description
func callable Block to run
user Str? Account to use instead of root
cd Path? Initial elevated directory
env Dict Initial environment overrides
Returns

The result of func.

Example
sudo.with do run cat /etc/shadow