GNU bug report logs - #20796
[PATCH] Document behavior of sed -i -

Previous Next

Package: sed;

Reported by: Stanislav Brabec <sbrabec <at> suse.com>

Date: Fri, 12 Jun 2015 15:34:02 UTC

Severity: normal

Tags: patch

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Jim Meyering <jim <at> meyering.net>
To: Stanislav Brabec <sbrabec <at> suse.com>
Cc: 20796 <20796 <at> debbugs.gnu.org>
Subject: bug#20796: [PATCH] Document behavior of sed -i -
Date: Mon, 22 Jun 2015 07:06:46 -0700
On Mon, Jun 22, 2015 at 6:43 AM, Stanislav Brabec <sbrabec <at> suse.com> wrote:
> Jim Meyering wrote:
>
>> However, rather than documenting this surprising behavior,
>> I propose to remove the anomaly altogether with the attached patch.
>> Does anyone see a reason to retain the behavior of treating "-"
>> like "./-"?
>>
> The reason is simple: "sed -i" makes no sense on stdin, so the special
> handling od "-" is disabled.
>
> We can either ignore "-i" for stdin, or report error:
> "Editing standard input in place is an undefined operation."

Ignoring a fundamental user-specified option like -i is not an option,
so I chose the latter: to make this nonsensical usage evoke
a diagnostic:

  $ sed -i s/a/b/ -
  sed: couldn't edit -: is a terminal

I chose to use the same diagnostic that was already printed for
a case like "sed -i s/a/b/ /dev/stdin".  It feels slightly better to
include the name of the offending device.




This bug report was last modified 10 years and 27 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.