Blame SOURCES/sudo.sh

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