21 lines
521 B
Bash
21 lines
521 B
Bash
#!/bin/bash
|
|
|
|
fsudo () # run a function as sudo
|
|
{
|
|
[[ "$(type -t $1)" == "function" ]] &&
|
|
ARGS="$@" && sudo bash -c "$(declare -f $1); $ARGS"
|
|
}
|
|
|
|
function Sudo {
|
|
local firstArg=$1
|
|
if [ $(type -t $firstArg) = function ]
|
|
then
|
|
shift && command sudo bash -c "$(declare -f $firstArg);$firstArg $*"
|
|
elif [ $(type -t $firstArg) = alias ]
|
|
then
|
|
alias sudo='\sudo '
|
|
eval "sudo $@"
|
|
else
|
|
command sudo "$@"
|
|
fi
|
|
} |