Blame SOURCES/sudo.sh

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