Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zsh can output non-printable characters to the terminal in some error messages



On Wed, Jun 10, 2026 at 10:01 AM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>
> Hmm, did you make the same mistake I did there? Eg, we didn't include
> the #!/bin/zsh shebang. My script was run with /bin/sh and I suspect
> so was yours?

You don't need zsh or sh to "expose" this ...

% mkdir /tmp/emptydir
% cd /tmp/emptydir
% touch file$'\033'\[H$'\033'\[c$'\n'$'\b'
% find . -print
(screen clears)
% cd ..
% rm -ri emptydir
examine files in directory emptydir? y
remove emptydir/file(cursor jumps up several lines, some garbage displayed)
(type "y" and enter)
remove emptydir? y
rm: emptydir: Directory not empty
%

With the notable exception of "ls", most tools do not sanitize
filename output.  However:

% zmodload zsh/files
% rm -ri emptydir
rm: remove `emptydir/file^[[H^[[c\n^H'? y
rm: remove `emptydir'? y
%




Messages sorted by: Reverse Date, Date, Thread, Author