Date: Sat, 12 Apr 2014 21:36:25 GMT From: Volodymyr Kostyrko <arcade@b1t.name> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/188535: ed/red - incorrectly sets current address upon removing last line Message-ID: <201404122136.s3CLaPgR084059@cgiserv.freebsd.org> Resent-Message-ID: <201404122140.s3CLe33p022029@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 188535 >Category: bin >Synopsis: ed/red - incorrectly sets current address upon removing last line >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Apr 12 21:40:02 UTC 2014 >Closed-Date: >Last-Modified: >Originator: Volodymyr Kostyrko >Release: ^/stable/10 >Organization: none >Environment: FreeBSD kohrah.xim.bz 10.0-RELEASE-p1 FreeBSD 10.0-RELEASE-p1 #1 r264316M: Thu Apr 10 16:38:26 EEST 2014 root@kohrah.xim.bz:/usr/obj/usr/src/sys/MINIMAL amd64 >Description: Let's have some file: echo xxx > some_file echo yyy >> some_file Now let's try to edit it with ed, lines starting from '>' are manual input: > ed some_file 8 > H > = 2 > g/yyy/d > = 2 > g/xxx/d > = 0 > g/zzz/d ? invalid address When last line is removed from file current address is changed from 1 to 0 making all subsequent range addressing to fail. This violates the man page: Since the g (global) command masks any errors from failed searches and substitutions, it can be used to perform conditional operations in scripts; -- What I mean is that actually using g (global) is not fully safe. Imagine I have a number of key fingerprints and I want to create a simple script to remove them from 'known_hosts' throughout all of my machines. There are a lot of fingerprints but each known_hosts file can contain only a few of them thus script may fail when file is running out of lines. >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201404122136.s3CLaPgR084059>