From b82afb68645b835f0b75b5e21e93203713f4af01 Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Fri, 2 Aug 2024 07:01:22 +0000 Subject: automatic import of gcc-toolset-14 --- sudo.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 sudo.sh (limited to 'sudo.sh') diff --git a/sudo.sh b/sudo.sh new file mode 100644 index 0000000..7feaa8f --- /dev/null +++ b/sudo.sh @@ -0,0 +1,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 + +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" -- cgit v1.2.3