zsh-users
 help / color / mirror / code / Atom feed
* redirecting stdout of no/empty command
@ 2012-01-06 18:34 Isaac Huang
  2012-01-06 18:43 ` Daniel Shahaf
  0 siblings, 1 reply; 5+ messages in thread
From: Isaac Huang @ 2012-01-06 18:34 UTC (permalink / raw)
  To: zsh-users

Hi list,

I noticed a zsh behaviour today. If I tried to run '>/dev/null' (i.e.
stdout redirection of no command at all) on an interactive zsh, the
zsh would actually run a 'cat', and it wouldn't exit until a ^D or ^C.

The same thing on bash seemed to be a no-op. I wonder why zsh would
run 'cat' when it was given no command to run at all.

Please CC me as I'm not on the list. Thanks.

- Isaac


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: redirecting stdout of no/empty command
  2012-01-06 18:34 redirecting stdout of no/empty command Isaac Huang
@ 2012-01-06 18:43 ` Daniel Shahaf
  2012-01-06 19:07   ` Damien Thébault
       [not found]   ` <CAEcrOvDimRXcWSrjnuasfQGy0F66xAg1bxTGmjMQ2_cgXCwKvQ__39184.4791862697$1325877047$gmane$org@mail.gmail.com>
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Shahaf @ 2012-01-06 18:43 UTC (permalink / raw)
  To: Isaac Huang; +Cc: zsh-users

Isaac Huang wrote on Fri, Jan 06, 2012 at 11:34:26 -0700:
> Hi list,
> 
> I noticed a zsh behaviour today. If I tried to run '>/dev/null' (i.e.
> stdout redirection of no command at all) on an interactive zsh, the
> zsh would actually run a 'cat', and it wouldn't exit until a ^D or ^C.
> 
> The same thing on bash seemed to be a no-op.

Actually it truncates the file.

$ echo foo>1
$ >1
$ cat 1
$ 

> I wonder why zsh would
> run 'cat' when it was given no command to run at all.
> 

As a shorthand.

See also NULLCMD and READNULLCMD in zshall(1).

> Please CC me as I'm not on the list. Thanks.
> 
> - Isaac


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: redirecting stdout of no/empty command
  2012-01-06 18:43 ` Daniel Shahaf
@ 2012-01-06 19:07   ` Damien Thébault
  2012-01-06 19:20     ` Daniel Shahaf
       [not found]   ` <CAEcrOvDimRXcWSrjnuasfQGy0F66xAg1bxTGmjMQ2_cgXCwKvQ__39184.4791862697$1325877047$gmane$org@mail.gmail.com>
  1 sibling, 1 reply; 5+ messages in thread
From: Damien Thébault @ 2012-01-06 19:07 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: Isaac Huang, zsh-users

On Fri, Jan 6, 2012 at 19:43, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> Isaac Huang wrote on Fri, Jan 06, 2012 at 11:34:26 -0700:
>> Hi list,
>>
>> I noticed a zsh behaviour today. If I tried to run '>/dev/null' (i.e.
>> stdout redirection of no command at all) on an interactive zsh, the
>> zsh would actually run a 'cat', and it wouldn't exit until a ^D or ^C.
>>
>> The same thing on bash seemed to be a no-op.
>
> Actually it truncates the file.
>
> $ echo foo>1
> $ >1
> $ cat 1
> $
>

I have the same behaviour than Isaac:

luke% zsh -f
luke% >file1
[Typing Hello, World^D^D]
luke% cat file1
Hello, World
luke%

(It's not affecting me much since when I need to have empty input, I
use cat /dev/null or echo -n "")

-- 
Damien Thebault


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: redirecting stdout of no/empty command
  2012-01-06 19:07   ` Damien Thébault
@ 2012-01-06 19:20     ` Daniel Shahaf
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Shahaf @ 2012-01-06 19:20 UTC (permalink / raw)
  To: Damien Thébault; +Cc: Isaac Huang, zsh-users

Damien Thébault wrote on Fri, Jan 06, 2012 at 20:07:35 +0100:
> On Fri, Jan 6, 2012 at 19:43, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> > Isaac Huang wrote on Fri, Jan 06, 2012 at 11:34:26 -0700:
> >> Hi list,
> >>
> >> I noticed a zsh behaviour today. If I tried to run '>/dev/null' (i.e.
> >> stdout redirection of no command at all) on an interactive zsh, the
> >> zsh would actually run a 'cat', and it wouldn't exit until a ^D or ^C.
> >>
> >> The same thing on bash seemed to be a no-op.
> >
> > Actually it truncates the file.
> >
> > $ echo foo>1
> > $ >1
> > $ cat 1
> > $
> >
> 
> I have the same behaviour than Isaac:
> 

So do I.  My earleir mail described bash's behaviour, not zsh's.

> luke% zsh -f
> luke% >file1
> [Typing Hello, World^D^D]
> luke% cat file1
> Hello, World
> luke%
> 
> (It's not affecting me much since when I need to have empty input, I
> use cat /dev/null or echo -n "")
> 
> -- 
> Damien Thebault


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: redirecting stdout of no/empty command
       [not found]   ` <CAEcrOvDimRXcWSrjnuasfQGy0F66xAg1bxTGmjMQ2_cgXCwKvQ__39184.4791862697$1325877047$gmane$org@mail.gmail.com>
@ 2012-01-06 20:36     ` Stephane Chazelas
  0 siblings, 0 replies; 5+ messages in thread
From: Stephane Chazelas @ 2012-01-06 20:36 UTC (permalink / raw)
  To: Damien Thébault; +Cc: Daniel Shahaf, Isaac Huang, zsh-users

2012-01-06 20:07:35 +0100, Damien Thébault:
[...]
> (It's not affecting me much since when I need to have empty input, I
> use cat /dev/null or echo -n "")
[...]

The usual way to do it is:

: > foo

-- 
Stephane


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-01-06 20:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-06 18:34 redirecting stdout of no/empty command Isaac Huang
2012-01-06 18:43 ` Daniel Shahaf
2012-01-06 19:07   ` Damien Thébault
2012-01-06 19:20     ` Daniel Shahaf
     [not found]   ` <CAEcrOvDimRXcWSrjnuasfQGy0F66xAg1bxTGmjMQ2_cgXCwKvQ__39184.4791862697$1325877047$gmane$org@mail.gmail.com>
2012-01-06 20:36     ` Stephane Chazelas

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).