|
|
aee28c |
#! /bin/bash
|
|
|
aee28c |
|
|
|
aee28c |
# Emulate /usr/bin/sudo, so that SCL environment variables
|
|
|
aee28c |
# are passed through via an /bin/env wrapper.
|
|
|
aee28c |
# Includes work by Andy Fong <boringuy@gmail.com>
|
|
|
aee28c |
|
|
|
aee28c |
cmd_started=false
|
|
|
aee28c |
is_option_param_next=false
|
|
|
aee28c |
for arg in "$@"
|
|
|
aee28c |
do
|
|
|
aee28c |
case "$arg" in
|
|
|
aee28c |
*\'*)
|
|
|
aee28c |
arg= ;;
|
|
|
aee28c |
esac
|
|
|
aee28c |
if [ "$cmd_started" = true ]; then
|
|
|
aee28c |
cmd_options="$cmd_options '$arg'"
|
|
|
aee28c |
elif [ "$is_option_param_next" = true ]; then
|
|
|
aee28c |
sudo_options="$sudo_options $arg"
|
|
|
aee28c |
is_option_param_next=false
|
|
|
aee28c |
elif [[ $arg == -* ]]; then
|
|
|
aee28c |
sudo_options="$sudo_options $arg"
|
|
|
aee28c |
case "$arg" in
|
|
|
aee28c |
# all the options that take a parameter
|
|
|
aee28c |
"-g" | "-h" | "-p" | "-u" | "-U" | "-C" | "-s" | "-r" | "-t" | "-T")
|
|
|
aee28c |
is_option_param_next=true
|
|
|
aee28c |
;;
|
|
|
aee28c |
"--")
|
|
|
aee28c |
cmd_started=true
|
|
|
aee28c |
;;
|
|
|
aee28c |
esac
|
|
|
aee28c |
elif [[ $arg == *=* ]]; then
|
|
|
aee28c |
sudo_options="$sudo_options $arg"
|
|
|
aee28c |
else
|
|
|
aee28c |
cmd_options="$cmd_options '$arg'"
|
|
|
aee28c |
cmd_started=true
|
|
|
aee28c |
fi
|
|
|
aee28c |
done
|
|
|
aee28c |
if [ "$sudo_options" == "" ]; then
|
|
|
aee28c |
sudo_options="-E"
|
|
|
aee28c |
fi
|
|
|
aee28c |
exec /usr/bin/sudo $sudo_options env LD_LIBRARY_PATH=$LD_LIBRARY_PATH PATH=$PATH scl enable %{scl} "$cmd_options"
|