[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] sed: reject r/R/w/W commands without a filename
From: |
Jim Meyering |
Subject: |
Re: [PATCH] sed: reject r/R/w/W commands without a filename |
Date: |
Thu, 18 Oct 2018 22:42:50 -0700 |
On Thu, Oct 18, 2018 at 3:50 AM Assaf Gordon <address@hidden> wrote:
> Hello,
>
> Attached a small patch to improve error messages when a filename is
> missing.
>
> ---
>
> For w/W (and s///w) commands this is a simple improvement of the
> (previously confusing) error message.
>
> For r/R commands, this might be considered a backwards-incompatible
> change:
>
> $ sed-4.5 r < /dev/null && echo ok
> OK
> $ sed-new r < /dev/null && echo ok
> sed-new: -e expression #1, char 1: missing filename in r/R/w/W commands
>
> However,
> This makes GNU sed's behaviour match FreeBSD's and Busybox's sed:
>
> FreeBSD:
> $ sed r
> sed: 1: "r": filename expected
> $ sed w
> sed: 1: "w": filename expected
> $ sed 's/1/x/w'
> sed: 1: "s/1/x/w": no wfile specified
>
> BusyBox:
> $ busybox sed r
> sed: empty filename
> $ busybox sed w
> sed: empty filename
>
> ---
>
> If it is desired to keep the existing (no-op) behavior of r/R commands,
> I can easily adjust the patch.
Hi Assaf,
I think your change is the right solution, and found no room for
improvement in the patch. Thanks a lot.