From owner-svn-src-head@freebsd.org Tue Dec 5 14:57:28 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7CE3CE6C943; Tue, 5 Dec 2017 14:57:28 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [88.99.82.50]) (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 3B51F7DD99; Tue, 5 Dec 2017 14:57:27 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (unknown [62.141.128.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 50E682603A1; Tue, 5 Dec 2017 15:57:23 +0100 (CET) Subject: Re: svn commit: r326554 - in head: . usr.bin/sponge usr.bin/sponge/tests usr.bin/tee To: Konstantin Belousov Cc: rgrimes@freebsd.org, cem@freebsd.org, Eitan Adler , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201712051258.vB5CwjQN051356@pdx.rh.CN85.dnsmgr.net> <22918eec-4c98-01e4-4c63-e145fbc6eab9@selasky.org> <20171205134409.GV2272@kib.kiev.ua> From: Hans Petter Selasky Message-ID: <5bd30132-aac7-e636-04c5-e57cbd65c54b@selasky.org> Date: Tue, 5 Dec 2017 15:54:38 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171205134409.GV2272@kib.kiev.ua> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Dec 2017 14:57:28 -0000 On 12/05/17 14:44, Konstantin Belousov wrote: > On Tue, Dec 05, 2017 at 02:00:00PM +0100, Hans Petter Selasky wrote: >> On 12/05/17 13:58, Rodney W. Grimes wrote: >>> Further more, why does freebsd need this in base? >> Hi, >> >> I think this is useful. It could replace the "-i " (intermediate) option >> for "sed" for example. It avoids creating temporary files when filtering >> files, right? Hi, > No, if process fails during the operation, user data is destroyed > irretrievable. It depends what you are doing. If the compiler crashes while outputting an object file and the atexit() hooks fail to remove the object file and you re-run the build, bad things can still happen and nobody will notice. From what I can see users must be aware of the limitations of any command they use in a script. Should probably be noted in the sponge manual page. sponge could also have an atexit() hook to remove the processed file upon failure. Typically when patching files in packages, it is a waste of system resources to have a three step procedure, mv-process-mv, because when the build is complete the files will be deleted anyway .... >The usual trick of creating temporary file and renaming > ensure that old file is around until all data for new file is written > into buffer cache. With some existing filesystem support, it also > guarantees that the old file is around in case of the system crash. This process could also be automated with sponge. If some option XXX is set, backup the file first in a safe way, before writing it new. Further because sponge is a single utility, it can lock the files in question through the whole procedure to make the operation atomic w.r.t. the file system. Can you lock files from scripts? And what about performance and complexity? > > All this assuming the tool' code matches its description, which is not. --HPS