You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
903 B
Bash
51 lines
903 B
Bash
#!/usr/bin/env bash
|
|
|
|
sudo_args=()
|
|
|
|
while [[ $# -gt 0 ]] ; do
|
|
token="${1}"
|
|
|
|
#rvm trace flag
|
|
case "${token}" in
|
|
(--trace)
|
|
export PS4="+ \${BASH_SOURCE##\${gvm_path:-}} : \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} > "
|
|
set -o xtrace
|
|
;;
|
|
|
|
#rvm verbose flag
|
|
(--verbose)
|
|
set -o verbose
|
|
;;
|
|
|
|
#not an rvm option, treat as sudo option
|
|
(-*)
|
|
sudo_args+=("$token")
|
|
|
|
#option with value
|
|
case "$token" in
|
|
(-g|-u|-p|-r|-t|-U|-C)
|
|
shift
|
|
#read & append the value
|
|
sudo_args+=("$1")
|
|
;;
|
|
esac
|
|
;;
|
|
|
|
#no more options skip processing
|
|
(*)
|
|
break
|
|
;;
|
|
esac
|
|
|
|
#go to next param
|
|
shift
|
|
done
|
|
|
|
if [[ $# -gt 0 ]]
|
|
then
|
|
eval sudo "${sudo_args[@]}" /usr/bin/env "$(/usr/bin/env | grep -E '^GO|^GVM|^PATH' | sed 's/=\(.*\)$/="\1"/' )" "$@"
|
|
else
|
|
printf "Usage:\n %s [--trace] [--verbose] [sudo-options] command [command-options]\n $0"
|
|
fi
|
|
|