diff options
author | CoprDistGit <infra@openeuler.org> | 2024-08-05 02:00:53 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2024-08-05 02:00:53 +0000 |
commit | c086c409cb9b1c5976bcf707a27d2ae755f7805d (patch) | |
tree | 0d1ab6b570a647748f76fce48321b2f433918553 /sudo.sh | |
parent | 2d8fe24b2d55e5aadaf810c4f46198391fa43ffd (diff) |
automatic import of gcc-toolset-14openeuler24.03_LTS
Diffstat (limited to 'sudo.sh')
-rw-r--r-- | sudo.sh | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -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 <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" |