Revision 14850
Added by Aaron Marcuse-Kubitza about 10 years ago
trunk/lib/sh/util.sh | ||
---|---|---|
493 | 493 |
sudo_cmd_wrapper=(env PATH="$PATH") # preserve PATH |
494 | 494 |
|
495 | 495 |
func_override sudo__basic |
496 |
function sudo() |
|
496 |
function sudo() # preserves PATH; only runs sudo if needed
|
|
497 | 497 |
{ |
498 | 498 |
echo_func |
499 |
if is_callable "$1"; then set -- "${sudo_cmd_wrapper[@]}" "$@"; fi |
|
500 |
sudo__basic "$@" |
|
499 |
if is_callable "$1"; then # using sudo with command |
|
500 |
if test "$is_root"; then "$@" # don't need sudo |
|
501 |
else sudo__basic "${sudo_cmd_wrapper[@]}" "$@" |
|
502 |
fi |
|
503 |
else sudo__basic "$@" # using sudo with just options |
|
504 |
fi |
|
501 | 505 |
} |
502 | 506 |
alias sudo='"sudo" ' # last space alias-expands next word |
503 | 507 |
|
Also available in: Unified diff
lib/sh/util.sh: sudo(): only run sudo if needed