[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] sed: reject r/R/w/W commands without a filename
From: |
Assaf Gordon |
Subject: |
[PATCH] sed: reject r/R/w/W commands without a filename |
Date: |
Thu, 18 Oct 2018 04:49:25 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 |
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.
Comments welcomed,
- assaf
0001-sed-reject-r-R-w-W-commands-without-a-filename.patch
Description: Text Data
- [PATCH] sed: reject r/R/w/W commands without a filename,
Assaf Gordon <=