Blame SOURCES/sudo.sh

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