Blame SOURCES/sudo.sh

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