Permalink
Browse files

added method net_bazzline_execute_as_super_user_when_not_beeing_root

  • Loading branch information...
stevleibelt committed Oct 4, 2016
1 parent 638861d commit 6a3116786217c185efbe2b05abef16a95292883c
Showing with 26 additions and 0 deletions.
  1. +26 −0 function
View
@@ -570,6 +570,32 @@ function net_bazzline_diff_directory ()
fi
}
#e
####
# Adds "sudo" before the provided command if you are not root
#
# @param string $command_to_execute
####
function net_bazzline_execute_as_super_user_when_not_beeing_root ()
{
net_bazzline_record_function_usage ${FUNCNAME[0]}
if [[ $# -lt 1 ]];
then
echo "Invalid number of arguments provided"
echo "${FUNCNAME[0]} <command to execute>"
return 1
fi
if [[ $(whoami) == "root" ]];
then
$@
else
sudo $@
fi
}
#f
####

0 comments on commit 6a31167

Please sign in to comment.