Blame SOURCES/sudo.sh

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