$> file
在bash(也是破折号)中,文件被截断(或者如果它不存在则创建),然后提示返回.在zsh中,文件被截断/创建,但它会挂起.您必须使用Ctrl-C才能再次使用提示.
zsh$cat nonempty.file > file zsh$
问题是:
是否期望这种行为? zsh错了吗?
更新:
在zsh手册中找到了这个:
REDIRECTIONS WITH NO COMMAND:
When a simple command consists of one or more redirection operators and zero or more parameter assignments,but no command name, @H_404_32@zsh can behave in several ways.
If the parameter @H_404_32@NULLCMD is not set or the option @H_404_32@CSH_NULLCMD is set,an error is caused. This is the @H_404_32@csh behavior
and @H_404_32@CSH_NULLCMD is set by default when emulating @H_404_32@csh.If the option @H_404_32@SH_NULLCMD is set,the builtin @H_404_32@: is inserted as a command with the given redirections. This is the
default when emulating @H_404_32@sh or @H_404_32@ksh.Otherwise,if the parameter @H_404_32@NULLCMD is set,its value will be used as a command with the given redirections. If both
@H_404_32@NULLCMD and @H_404_32@READNULLCMD are set,then the value of the latter will be used instead of that of the former when the
redirection is an input. The default for @H_404_32@NULLCMD is @H_404_32@cat and for @H_404_32@READNULLCMD is @H_404_32@more.在我的系统上,默认为:
$echo $ZSH_VERSION 4.3.10 $echo $NULLCMD cat $echo $READNULLCMD /usr/bin/pager $