Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Sep 2002 16:57:33 +0200
From:      Jasper Jongmans <j.jongmans@aprogas.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/42596: sed_inplace fails on symlinks and truncates the file and backup
Message-ID:  <20020909145733.GA520@harry.aprogas.net>

next in thread | raw e-mail | index | archive | help

>Number:         42596
>Category:       ports
>Synopsis:       sed_inplace fails on symlinks and truncates the file and backup
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 09 08:00:11 PDT 2002
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020909145733.GA520>