From owner-freebsd-ports Mon Sep 9 8: 0:22 2002 Delivered-To: freebsd-ports@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 66B7C37B400 for ; Mon, 9 Sep 2002 08:00:14 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 383C343E6E for ; Mon, 9 Sep 2002 08:00:13 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g89F0DJU014912 for ; Mon, 9 Sep 2002 08:00:13 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g89F0DCm014911; Mon, 9 Sep 2002 08:00:13 -0700 (PDT) Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C9CEA37B401 for ; 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 ; 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 ; 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 Reply-To: Jasper Jongmans To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/42596: sed_inplace fails on symlinks and truncates the file and backup Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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 >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