Blame SOURCES/sudo.sh

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