bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feature: disallow | >


From: Bob Proulx
Subject: Re: Feature: disallow | >
Date: Wed, 18 Mar 2015 18:12:10 -0600
User-agent: Mutt/1.5.23 (2014-03-12)

Ed Avis wrote:
> Thanks.  So 'whoami | >out' working is a natural consequence of the
> fact that '>out' is a command by itself.

It is a natural consequence of parsing redirections before parsing
commands.  The redirection happens before the command execution and an
empty command is valid.  That redirections happen in an earlier pass
across the command line is why they can occur anywhere in the command.
By convention we put rediections at the end.  But they can also
validly occur first (as the previous example showed) or in the middle.

> IMHO it would have been better for the Unix shell to forbid that,
> and require ': >out' if you really do want to run the null command
> and redirect its output, but it's too late now.

If it did then it would be incompatible with all of the rest that
allow it.  As I recall one of the obscure fringe Unix lookalike
systems did exactly that in their shell.  I forget details now.  But
because of that some of us do always use ":" instead of an empty
redirection simply due to it.

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]