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

Re: zsh blocks at file truncation



On 2013-09-21 at 12:40 +0530, chandan wrote:
> On zsh, Why does the following block indefinitely?
> 
> $ >file.txt

That's a bare redirection, which means that you're invoking the empty
command.  In bash, that invokes ":", also known as "true".  By
_default_, in zsh, that's "cat" for writing and "more" for reading.

See "REDIRECTIONS WITH NO COMMAND" in zshmisc(1) [or zshall(1)].

So you can either:

    setopt sh_nullcmd

or set:

    NULLCMD=: READNULLCMD=:

to get the behaviour which you're used to.

For myself, I very often invoke:

% >/dev/null

to get a scratch space for fast notes which I don't want to live in
editor swap files, or testing input echo'ing in a terminal without
having a program other than the kernel and the terminal emulator try to
interpret the keystrokes.



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