blob: 7feaa8f61db6b9e85c9d9c7f313647e337e81456 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#! /bin/bash
# Emulate /usr/bin/sudo, so that SCL environment variables
# are passed through via an /bin/env wrapper.
# Includes work by Andy Fong <boringuy@gmail.com>
cmd_started=false
is_option_param_next=false
for arg in "$@"
do
case "$arg" in
*\'*)
arg= ;;
esac
if [ "$cmd_started" = true ]; then
cmd_options="$cmd_options '$arg'"
elif [ "$is_option_param_next" = true ]; then
sudo_options="$sudo_options $arg"
is_option_param_next=false
elif [[ $arg == -* ]]; then
sudo_options="$sudo_options $arg"
case "$arg" in
# all the options that take a parameter
"-g" | "-h" | "-p" | "-u" | "-U" | "-C" | "-s" | "-r" | "-t" | "-T")
is_option_param_next=true
;;
"--")
cmd_started=true
;;
esac
elif [[ $arg == *=* ]]; then
sudo_options="$sudo_options $arg"
else
cmd_options="$cmd_options '$arg'"
cmd_started=true
fi
done
if [ "$sudo_options" == "" ]; then
sudo_options="-E"
fi
exec /usr/bin/sudo $sudo_options env LD_LIBRARY_PATH=$LD_LIBRARY_PATH PATH=$PATH scl enable %{scl} "$cmd_options"
|