diff --git a/scripts/wk/exe.py b/scripts/wk/exe.py index 17f49249..e49b51d6 100644 --- a/scripts/wk/exe.py +++ b/scripts/wk/exe.py @@ -3,6 +3,7 @@ import json import logging +import os import re import subprocess @@ -77,6 +78,10 @@ def build_cmd_kwargs(cmd, minimized=False, pipe=True, shell=False, **kwargs): 'shell': shell, } + # Strip sudo if appropriate + if cmd[0] == 'sudo' and os.name == 'posix' and os.geteuid() == 0: + cmd.pop(0) + # Add additional kwargs if applicable for key in 'check cwd encoding errors stderr stdin stdout'.split(): if key in kwargs: