zinit icon indicating copy to clipboard operation
zinit copied to clipboard

[bug]: zsh-autocomplete creates file called $'\374'$'\227'$'\374'$'\233'$'\374' in working directory when completing [[ with long lines in history file and terminal in 256 color mode

Open raxod502 opened this issue 1 year ago • 0 comments

What happened?

Exactly what it says in the title.

Yes, I know this sounds insane. Because of that I have produced a ready to execute Dockerfile that reproduces the issue, see below. If I get rid of any of the requirements mentioned in the issue title, the problem no longer occurs.

Reporting the bug here because per the maintainer of zsh-autocomplete, this is the fault of zinit: https://github.com/marlonrichert/zsh-autocomplete/issues/588#issuecomment-1556551280

Steps to reproduce

Build and run the following Dockerfile:

FROM ubuntu:22.04
RUN apt-get update
RUN apt-get install -y zsh
RUN apt-get install -y curl
RUN apt-get install -y git
RUN chsh -s /usr/bin/zsh
CMD ["zsh"]
RUN git clone https://github.com/zdharma-continuum/zinit.git ~/.zinit
RUN curl https://gist.githubusercontent.com/raxod502/2952e2370f11fe2ff8dc69b7b728de8a/raw/607f386c9a7649d393663f3032837308cb971ddb/wtf.txt > /root/.zsh_history
RUN echo 'source ~/.zinit/zinit.zsh' >> ~/.zshrc
RUN echo 'zinit light marlonrichert/zsh-autocomplete' >> ~/.zshrc
RUN echo 'HISTFILE=~/.zsh_history' >> ~/.zshrc
WORKDIR /opt

E.g., docker build . -t bug && docker run -it --rm bug.

Then, perform the following steps:

wit% sudo docker run -it --rm bug 

Downloading marlonrichert/zsh-autocomplete...
Cloning into '/root/.zinit/plugins/marlonrichert---zsh-autocomplete'...
⠸ █████████████████████████ OBJ: 100, PACK: 4013/4013, COMPR: 100%, REC: 100%, RES: 100%          
==> Compiling zsh-autocomplete.plugin.zsh [OK]
==> Installed 8 completions
cdb4ff385b90# env -i TERM=xterm-256color zsh
cdb4ff385b90# ls -lA
total 0
cdb4ff385b90# [[
cdb4ff385b90# ls -lA
total 0
-rw-r--r-- 1 root root 0 May 13 03:34 ''$'\374\227\374\233\374'

In the step where I type [[, I include a space after the [[ and then press ^C to abort the command. Deleting the typed characters also works. The point is to trigger autocompletions for [[. Observe that a file called $'\374'$'\227'$'\374'$'\233'$'\374' has somehow appeared in the working directory, which was previously empty.

Just to make sure this wasn't a problem with the terminal emulator on my machine, I signed up for a free account on Google Cloud Shell and ran the same test case there, with the same result:

image

Relevant output

No response

Screenshots and recordings

image

Operating System & Version

OS: linux-gnu | Vendor: ubuntu | Machine: x86_64 | CPU: x86_64 | Processor: x86_64 | Hardware: x86_64

Zsh version

zsh 5.8.1 (x86_64-ubuntu-linux-gnu)

Terminal emulator

xterm-256color

If using WSL on Windows, which version of WSL

None

Additional context

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

raxod502 avatar May 22 '23 20:05 raxod502