1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-30 17:50:07 +00:00

do not resolve command to absolute path

it breaks commands e.g. sudo -u http echo foobar as http is both a
command (httpie) and a user/group (httpd) in my system
This commit is contained in:
Frederick Zhang 2019-10-18 21:41:39 +11:00
parent 7f4d633f46
commit 557234e352
No known key found for this signature in database
GPG key ID: 980A192C361BE1AE

View file

@ -17,14 +17,10 @@ function _do_sudo() {
noglob) __do_sudo_glob=0; shift ;; noglob) __do_sudo_glob=0; shift ;;
*) *)
cmd_alias="$(command -v 2>/dev/null -- "$1")" cmd_alias="$(command -v 2>/dev/null -- "$1")"
if [[ "$?" -eq 0 ]]; then if [[ "$?" -eq 0 ]] && [[ "$cmd_alias" == 'alias'* ]] && [[ -z "$__do_sudo_expanded["$1"]" ]]; then
if [[ "$cmd_alias" == 'alias'* ]] && [[ -z "$__do_sudo_expanded["$1"]" ]]; then
__do_sudo_expanded["$1"]=1 __do_sudo_expanded["$1"]=1
IFS=' ' read -A cmd_alias_arr <<< "$(sed -e "s/[^=]*=//" -e "s/^'//" -e "s/'$//" <<< "$cmd_alias")" IFS=' ' read -A cmd_alias_arr <<< "$(sed -e "s/[^=]*=//" -e "s/^'//" -e "s/'$//" <<< "$cmd_alias")"
args+=( "${cmd_alias_arr[@]}" ) args+=( "${cmd_alias_arr[@]}" )
else
args+=( "$(sed "s/[^=]*=//" <<< "$(hash -v 2>/dev/null -- "$1")")" )
fi
shift shift
break break
else else