Blame SOURCES/sudo.sh

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