Skip to content

Shadowing default echo with an alias/function can break autosuggestions #843

Open

Description

@Fruchix

Describe the bug

If the shell builtin "echo" is shadowed by an alias or a function, it is the alias/function that will be used by zsh-autosuggestions, which can break the autosuggestion by either printing a wrong suggestion, or executing an unwanted function.

To Reproduce

Steps to reproduce the behavior:

git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
zsh -df
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh

# example of printing the wrong suggestion
alias echo="builtin echo 'DEBUG: '"

# example of executing unwanted function
alias echo="ls; builtin echo 'DEBUG: '"

Expected behavior

I feel like zsh autosuggestions should always use the builtin echo, an being able to change the echo command is not a feature that could be beneficial.

Especially in src/async.zsh, the following "echo"s are vulnerable:

# Fork a process to fetch a suggestion and open a pipe to read from it
	builtin exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
		# Tell parent process our pid
		echo $sysparams[pid]

		# Fetch and print the suggestion
		local suggestion
		_zsh_autosuggest_fetch_suggestion "$1"
		echo -nE "$suggestion"
	)

Screenshots

Image Image

In the second screenshot, I believe the number 29970 comes from echo $sysparams[pid].

Desktop

  • OS + distribution: MacOS Sequoia
  • Zsh version: 5.9
  • Plugin version: 85919cd (latest tag is v0.7.1)

Activity

  1. Fruchix commented on Nov 5, 2025

    @Fruchix
    Author

    If this is indeed a bug I can review all .zsh files, force the usage of builtin echo and submit a PR.

  2. chelovechishko commented on Apr 1, 2026

    @chelovechishko

    Actually, with

    alias echo=" echo -n"

    autosuggestions will be disabled entirely (no output at all).
    So, thank you very much for helping to understand why it did not work at all for me (for so long).

  3. added a commit that references this issue on May 27, 2026
    3be7de7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions