2

In bash i can truncate a file with:

$ > file

However the same command in zsh hangs.

Is it possible to configure zsh to emulate bash when truncating files?

Zlemini
  • 151
  • 6
  • 2
    I believe the command you are thinking of in bash is `: > file`. Not sure what its equivalent is in zsh though. – DerfK Feb 10 '17 at 23:20
  • 2
    Yeah, use `:> file` in either as that is a) portable and b) avoids the read from stdin. – thrig Feb 11 '17 at 00:46

2 Answers2

3

Based on the feedback here, I discovered that setting the zsh NULLCMD parameter to : emulates bash.

% NULLCMD=:
% >file
% ls -l file
  -rw-r--r--  1 pfalstad        0 May 24 05:41 file

Source: http://zsh.sourceforge.net/Intro/intro_13.html

NULLCMD is indeed set to cat by default

Zlemini
  • 151
  • 6
2

zsh is not actually hanging, it's accepting input. If you want bash behaviour use ^D (ctrl-d) to send an EOF.

Jesusaur
  • 196
  • 3