text铛重定向(代码片段)

author author     2022-12-01     321

关键词:

# cat rh-toolset-redirect
#!/bin/bash -
#===============================================================================
#
#          FILE: rh-toolset-redirect.sh
#
#   DESCRIPTION: Redirect command to devtoolset command. This script is designed
#                to be the target of symlinks of the form:
#
#                <RedHatToolsetName>-redirect
#
#               e.g. 'devtoolset-redirect', or 'llvm-toolset-redirect'
#
#                And that symlink should in turn be the target of a versioned
#                tool name such as 'clang7' or 'g++6'
#
#                E.g. g++6. It will strip the toolset_version, and redirect
#                the arguments to the toolset version of <binary_name>
#
#                Additionally, an unversioned symlink to a versioned symlink 
#                will use the versioned symlink to determine the version.
#
#                E.g., if we have symlinks:
#
#                   clang --> clang7 --> llvm-toolset-redirect -> <this-script>
#
#                Invoking 'clang' will mean the version will be taken from
#                'clang7', and the toolset name will be 'llvm-toolset'.
#                This allows you to set a default version by
#                creating an unversioned symlink to the desired versioned
#                symlink.
#
#                The toolset to redirect to is taken from the penultimate
#                symlink (in the example 'llvm-toolset')
#
#       CREATED: 2017-07-18
#
#        AUTHOR: Anthony Dervish
#
#===============================================================================

set -o nounset                              # Treat unset variables as an error

Script="$BASH_SOURCE[0]"
ScriptDir="$( cd "$( dirname "$Script"  )" && pwd -P )"

function GetVersion() 
    local bname=$(basename $Script)
    local version=$(echo "$bname" | sed -E 's/^.*([0-9]+)$/\1/')
    if [[ "$version" != "$bname" ]]; then
        echo "$version"
    fi


ToolsetVersion=$(GetVersion "$Script")
if [[ -z "$ToolsetVersion" ]]; then
    if [[ -h "$Script" ]]; then
        Script="$ScriptDir/$(basename $(readlink "$Script"))"
        ToolsetVersion=$(GetVersion "$Script")
        if [[ -z "$ToolsetVersion" ]]; then
            echo "Symlink name to this script should end in an integer toolset version!" >&2
            exit 1
        fi
    fi
fi

if [[ ! -h "$Script" ]]; then
    echo "$Script should be a symlink to <toolset>-redirect, which in turn should be a"
    echo "symlink to this script."
    exit 1
fi


ToolsetSymlink=$(readlink "$Script")
UnversionedToolset="$ToolsetSymlink%-redirect"

OrigName=$(basename "$Script")
ToolsetName=$UnversionedToolset-$ToolsetVersion
ToolsetDir="/opt/rh/$ToolsetName"

if [[ ! -d "$ToolsetDir" ]]; then
    echo "Unknown $UnversionedToolset version '$ToolsetVersion'" >&2
    exit 1
fi

RedirectBaseDir="$ToolsetDir/root/bin"
ToolName=$OrigName%$ToolsetVersion
ToolBinary="$RedirectBaseDir/$ToolName"

cat <<EOF | sed 's/\"/\\"/g' |
$ToolBinary $@
EOF
exec scl enable "$ToolsetName" -

# vim: filetype=sh:

text重定向(代码片段)

查看详情

text重定向循环(代码片段)

查看详情

text阻止按钮重定向(代码片段)

查看详情

text重定向.htaccess(代码片段)

查看详情

text重定向旧域(代码片段)

查看详情

text重定向辅助域(代码片段)

查看详情

text重定向按钮单击(代码片段)

查看详情

text重定向到新域(代码片段)

查看详情

text剩余的重定向(代码片段)

查看详情

text强制重定向到httpsnextcloud(代码片段)

查看详情

text强制重定向到https(代码片段)

查看详情

text路由目的地重定向(代码片段)

查看详情

text为主题重定向kinsta(代码片段)

查看详情

text重定向管理仪表板页面(代码片段)

查看详情

text重定向和锚定滚动(代码片段)

查看详情

text重定向到https://www(代码片段)

查看详情

text重定向用户角色编辑器(代码片段)

查看详情

text位置(ip地址)重定向用户(代码片段)

查看详情