1

I had never heard of zsh before, but when I updated to Catalina, MacOS pushed me to drop bash in favor of zsh. But I recently have observed some annoying incompatibilities when trying to append to the end of a file using cat >>. The line I want to add is copy & pasted from elsewhere in the terminal:

$ cat >> test.txt
This is a test.

zsh: do you wish to see all 3734 possibilities (1867 lines)? 

In this case I pasted the whole line "This is a test." (including to the end of the line). Unlike bash, zsh will (sometimes?) print the pasted text in reverse video until I press return. In this case I pressed "Control-D" to indicate that I was done pasting in text. At this point, bash would give me the next prompt, but here, zsh gives me a message I don't understand. I'm strongly considering going back to bash. But I'm very curious: what does zsh think it is doing? Does anyone else see this as a bug, or at least a misfeature? It also doesn't seem to happen all the time. Sometimes instead I get the less confusing but still incorrect:

zsh: command not found: This
2
  • The reverse video is "bracketed paste mode" of your terminal emulator, not directly zsh's doing, though it (something in your zsh configuration, really) is probably asking the terminal to enable it. Bash actually supports that too, just not in v3.2. It shouldn't still be enabled once a command is running, only during line editing, so that at least is unexpected. It's unclear exactly what is going on in these examples or where the paste is falling over, though. Commented Feb 23, 2021 at 1:21
  • A ctrl-d at a non-empty prompt acts like tab (for completion), iirc. Did you maybe press Ctrl-D twice or something?
    – muru
    Commented Feb 23, 2021 at 5:03

1 Answer 1

1

If you first paste

cat >> test.txt

and press Enter, and then paste

This is a test.

and then

  • press Enter followed by ControlD, or
  • press ControlD twice,

you will get the result you're looking for (in the first case, with a line break after your input, and in the second case, without).


If you directly paste

cat >> test.txt
This is a test.

then the second line won't go to cat as input, but it will go to Zsh as a second line in your command line.

  • If you then press Enter, Zsh will try to execute both lines accordingly, leading to zsh: command not found: This.
  • If you then press ControlD, Zsh will attempt to list completions for you on the second line, potentially (but not always) leading to zsh: do you wish to see all 3734 possibilities (1867 lines)? (depending on when and where you do this).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .