Blame SOURCES/sudo.sh

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