Blame SOURCES/sudo.sh

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