Blame SOURCES/sudo.sh

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