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