From j.jongmans@aprogas.net  Mon Sep  9 07:57:38 2002
Return-Path: <j.jongmans@aprogas.net>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id C9CEA37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  9 Sep 2002 07:57:38 -0700 (PDT)
Received: from aprogas.student.utwente.nl (cal009307.student.utwente.nl [130.89.160.179])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 952EB43E65
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  9 Sep 2002 07:57:34 -0700 (PDT)
	(envelope-from j.jongmans@aprogas.net)
Received: from harry.aprogas.net (aprogas@localhost.aprogas.net [IPv6:::1])
	by aprogas.student.utwente.nl (8.12.3/8.12.3) with ESMTP id g89EvX6O015860
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 9 Sep 2002 16:57:33 +0200 (CEST)
	(envelope-from j.jongmans@aprogas.net)
Received: (from aprogas@localhost)
	by harry.aprogas.net (8.12.3/8.12.3/Submit) id g89EvXJu015859
	for FreeBSD-gnats-submit@freebsd.org; Mon, 9 Sep 2002 16:57:33 +0200 (CEST)
	(envelope-from j.jongmans@aprogas.net)
Message-Id: <20020909145733.GA520@harry.aprogas.net>
Date: Mon, 9 Sep 2002 16:57:33 +0200
From: Jasper Jongmans <j.jongmans@aprogas.net>
Reply-To: Jasper Jongmans <j.jongmans@aprogas.net>
To: FreeBSD-gnats-submit@freebsd.org
Subject: sed_inplace fails on symlinks and truncates the file and backup

>Number:         42596
>Category:       ports
>Synopsis:       sed_inplace fails on symlinks and truncates the file and backup
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    sobomax
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 09 08:00:11 PDT 2002
>Closed-Date:    Sat Oct 19 03:34:06 PDT 2002
>Last-Modified:  Sat Oct 19 03:34:06 PDT 2002
>Originator:     Jasper Jongmans <j.jongmans@aprogas.net>
>Release:        FreeBSD 4.6.2-RELEASE i386
>Organization:
>Environment:
System: FreeBSD harry.aprogas.net 4.6.2-RELEASE FreeBSD 4.6.2-RELEASE #20: Tue Aug 27 13:53:18 CEST 2002 root@harry.aprogas.net:/usr/obj/usr/src/sys/HARRY i386
>Description:
	When sed_inplace is used on files that are actually symlinks to other
	files (e.g. in the games/gltron port, e.g. system.h -> system_sdl.h) it
	does not function properly. It truncates the original file and the
	backup of that file.
>How-To-Repeat:
	% echo 'This line is long.' >test.txt
	% cat test.txt
	This line is long.
	% sed_inplace -i.bak -e 's/long/short/' test.txt
	% cat test.txt
	This line is short.
	% cat test.txt.bak
	This line is long.

	Nothing strange until now, but when using symlinks:

	% echo 'This line is long.' >test.txt
	% ln -s test.txt test.txt.ln
	% ls test.txt.ln
	lrwx------  1 aprogas  users  8 Sep  9 15:56 test.txt.ln@ -> test.txt
	% cat test.txt.ln
	This line is long.
	% sed_inplace -i.bak -e 's/long/short/' test.txt.ln
	% cat test.txt.ln
	This lin% cat test.txt.ln.bak
	This lin% 
>Fix:
	A work around could be to use the old-style inplace using perl:
	perl -pi -e 's/foo/bar/' file.txt

	Or if perl is not available:
	sed 's/foo/bar/' file.txt >file.txt.new && mv file.txt.new file.txt


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports->sobomax 
Responsible-Changed-By: ijliao 
Responsible-Changed-When: Mon Sep 16 10:36:50 PDT 2002 
Responsible-Changed-Why:  
over to maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=42596 
State-Changed-From-To: open->closed 
State-Changed-By: sobomax 
State-Changed-When: Sat Oct 19 03:33:22 PDT 2002 
State-Changed-Why:  
Should be fixed in upgrade to 2002.10.19 snapshot. Thank you for reporting! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=42596 
>Unformatted:
