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