From owner-freebsd-bugs@FreeBSD.ORG Sat Apr 12 21:40:03 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 778CF540 for ; Sat, 12 Apr 2014 21:40:03 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 53812121D for ; Sat, 12 Apr 2014 21:40:03 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s3CLe3sg022030 for ; Sat, 12 Apr 2014 21:40:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s3CLe33p022029; Sat, 12 Apr 2014 21:40:03 GMT (envelope-from gnats) Resent-Date: Sat, 12 Apr 2014 21:40:03 GMT Resent-Message-Id: <201404122140.s3CLe33p022029@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Volodymyr Kostyrko Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 621A9392 for ; Sat, 12 Apr 2014 21:36:26 +0000 (UTC) Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4D6701201 for ; Sat, 12 Apr 2014 21:36:26 +0000 (UTC) Received: from cgiserv.freebsd.org ([127.0.1.6]) by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s3CLaPoq084068 for ; Sat, 12 Apr 2014 21:36:25 GMT (envelope-from nobody@cgiserv.freebsd.org) Received: (from nobody@localhost) by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s3CLaPgR084059; Sat, 12 Apr 2014 21:36:25 GMT (envelope-from nobody) Message-Id: <201404122136.s3CLaPgR084059@cgiserv.freebsd.org> Date: Sat, 12 Apr 2014 21:36:25 GMT From: Volodymyr Kostyrko To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: bin/188535: ed/red - incorrectly sets current address upon removing last line X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Apr 2014 21:40:03 -0000 >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: