Blame SOURCES/sudo.sh

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