GNU bug report logs -
#20796
[PATCH] Document behavior of sed -i -
Previous Next
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
Message #25 received at 20796-done <at> debbugs.gnu.org (full text, mbox):
On Mon, Jun 22, 2015 at 7:06 AM, Jim Meyering <jim <at> meyering.net> wrote:
> 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.
I've pushed that change.
This bug report was last modified 10 years and 26 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.