Use builtin echo to avoid conflicts with user aliases
When users have an alias or function that shadows 'echo', it can break autosuggestions by either printing wrong suggestions or executing unwanted functions. This commit replaces all 'echo' calls with 'builtin echo' to ensure the shell's built-in echo is always used. Fixes: #843
This commit is contained in:
parent
85919cd1ff
commit
3be7de77ac
|
|
@ -34,12 +34,12 @@ _zsh_autosuggest_async_request() {
|
||||||
# Fork a process to fetch a suggestion and open a pipe to read from it
|
# Fork a process to fetch a suggestion and open a pipe to read from it
|
||||||
builtin exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
|
builtin exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
|
||||||
# Tell parent process our pid
|
# Tell parent process our pid
|
||||||
echo $sysparams[pid]
|
builtin echo $sysparams[pid]
|
||||||
|
|
||||||
# Fetch and print the suggestion
|
# Fetch and print the suggestion
|
||||||
local suggestion
|
local suggestion
|
||||||
_zsh_autosuggest_fetch_suggestion "$1"
|
_zsh_autosuggest_fetch_suggestion "$1"
|
||||||
echo -nE "$suggestion"
|
builtin echo -nE "$suggestion"
|
||||||
)
|
)
|
||||||
|
|
||||||
# There's a weird bug here where ^C stops working unless we force a fork
|
# There's a weird bug here where ^C stops working unless we force a fork
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ _zsh_autosuggest_capture_completion_widget() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# The completion has been added, print the buffer as the suggestion
|
# The completion has been added, print the buffer as the suggestion
|
||||||
echo -nE - $'\0'$BUFFER$'\0'
|
builtin echo -nE - $'\0'$BUFFER$'\0'
|
||||||
}
|
}
|
||||||
|
|
||||||
zle -N autosuggest-capture-completion _zsh_autosuggest_capture_completion_widget
|
zle -N autosuggest-capture-completion _zsh_autosuggest_capture_completion_widget
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,5 @@ _zsh_autosuggest_escape_command() {
|
||||||
setopt localoptions EXTENDED_GLOB
|
setopt localoptions EXTENDED_GLOB
|
||||||
|
|
||||||
# Escape special chars in the string (requires EXTENDED_GLOB)
|
# Escape special chars in the string (requires EXTENDED_GLOB)
|
||||||
echo -E "${1//(#m)[\"\'\\()\[\]|*?~]/\\$MATCH}"
|
builtin echo -E "${1//(#m)[\"\'\\()\[\]|*?~]/\\$MATCH}"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ _zsh_autosuggest_escape_command() {
|
||||||
setopt localoptions EXTENDED_GLOB
|
setopt localoptions EXTENDED_GLOB
|
||||||
|
|
||||||
# Escape special chars in the string (requires EXTENDED_GLOB)
|
# Escape special chars in the string (requires EXTENDED_GLOB)
|
||||||
echo -E "${1//(#m)[\"\'\\()\[\]|*?~]/\\$MATCH}"
|
builtin echo -E "${1//(#m)[\"\'\\()\[\]|*?~]/\\$MATCH}"
|
||||||
}
|
}
|
||||||
|
|
||||||
#--------------------------------------------------------------------#
|
#--------------------------------------------------------------------#
|
||||||
|
|
@ -534,7 +534,7 @@ _zsh_autosuggest_capture_completion_widget() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# The completion has been added, print the buffer as the suggestion
|
# The completion has been added, print the buffer as the suggestion
|
||||||
echo -nE - $'\0'$BUFFER$'\0'
|
builtin echo -nE - $'\0'$BUFFER$'\0'
|
||||||
}
|
}
|
||||||
|
|
||||||
zle -N autosuggest-capture-completion _zsh_autosuggest_capture_completion_widget
|
zle -N autosuggest-capture-completion _zsh_autosuggest_capture_completion_widget
|
||||||
|
|
@ -791,12 +791,12 @@ _zsh_autosuggest_async_request() {
|
||||||
# Fork a process to fetch a suggestion and open a pipe to read from it
|
# Fork a process to fetch a suggestion and open a pipe to read from it
|
||||||
builtin exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
|
builtin exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
|
||||||
# Tell parent process our pid
|
# Tell parent process our pid
|
||||||
echo $sysparams[pid]
|
builtin echo $sysparams[pid]
|
||||||
|
|
||||||
# Fetch and print the suggestion
|
# Fetch and print the suggestion
|
||||||
local suggestion
|
local suggestion
|
||||||
_zsh_autosuggest_fetch_suggestion "$1"
|
_zsh_autosuggest_fetch_suggestion "$1"
|
||||||
echo -nE "$suggestion"
|
builtin echo -nE "$suggestion"
|
||||||
)
|
)
|
||||||
|
|
||||||
# There's a weird bug here where ^C stops working unless we force a fork
|
# There's a weird bug here where ^C stops working unless we force a fork
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue