Project

General

Profile

« Previous | Next » 

Revision 14849

lib/sh/util.sh: sudo(): factored PATH-preserving code out into separate wrapper var that can also be used separately, eg. with `sudo -u`

View differences:

trunk/lib/sh/util.sh
489 489

  
490 490
function sudo() { self -E "$@"; }
491 491

  
492
# usage: sudo -u user "${sudo_cmd_wrapper[@]}" "$@"
493
sudo_cmd_wrapper=(env PATH="$PATH") # preserve PATH
494

  
492 495
func_override sudo__basic
493 496
function sudo()
494 497
{
495 498
	echo_func
496
	if is_callable "$1"; then set -- env PATH="$PATH" "$@"; fi # preserve PATH
499
	if is_callable "$1"; then set -- "${sudo_cmd_wrapper[@]}" "$@"; fi
497 500
	sudo__basic "$@"
498 501
}
499 502
alias sudo='"sudo" ' # last space alias-expands next word

Also available in: Unified diff