[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature: disallow | >
From: |
Dan Douglas |
Subject: |
Re: Feature: disallow | > |
Date: |
Wed, 18 Mar 2015 09:27:07 -0500 |
On Tue, Mar 17, 2015 at 11:40 AM, Ed Avis <eda@waniasset.com> wrote:
> In bash, the empty command can be redirected to a file:
>
> % >out
>
> It will create or overwrite 'out' as the empty file. That may be useful.
> But somehow you can also say
>
> % whoami | >out
This isn't surprising or deserving of a special case treatment. It's a
valid permutation that I would expect to work as required.
This isn't even close to the most likely way one might screw up a
redirect. Forgetting a quote or escape in a non-obvious place such as
within an assignment or argument to a command is far more likely to
bite you. Examples:
var=foo>out
let x>5\?y:z
If you're worried about making a mistake, enable the noclobber option
in your bashrc.
--
Dan Douglas