From owner-freebsd-hackers@FreeBSD.ORG Fri Jul 16 07:59:49 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8CD2416A4CE; Fri, 16 Jul 2004 07:59:49 +0000 (GMT) Received: from mail.teledes.ru (host241-net53-vved7.miran.ru [213.221.53.241]) by mx1.FreeBSD.org (Postfix) with ESMTP id DFD8A43D3F; Fri, 16 Jul 2004 07:59:48 +0000 (GMT) (envelope-from DAntrushin@mail.ru) Received: from [10.1.1.31] ([10.1.1.31]) (authenticated bits=0) by mail.teledes.ru (8.12.11/8.12.11) with ESMTP id i6G7qOWx020598; Fri, 16 Jul 2004 11:52:25 +0400 (MSD) Message-ID: <40F78A8F.2010502@mail.ru> Date: Fri, 16 Jul 2004 11:58:07 +0400 From: Denis Antrushin User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7) Gecko/20040609 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Alfred Perlstein References: <20040716071545.GW95729@elvis.mu.org> <20040716072341.GX95729@elvis.mu.org> In-Reply-To: <20040716072341.GX95729@elvis.mu.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: hackers@freebsd.org Subject: Re: RFC: "-exit" option for find(1) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jul 2004 07:59:49 -0000 Alfred Perlstein wrote: > I'm up too late, this doesn't work because find returns > success whenever it successfully runs thought everything. > > Perhaps the primary change to just "-exit" which would > make find exit successfully, and if the primary is never > encountered (ie. our find logic never hits it) find would > exit with a non-zero exit status? > > Ideas? Better ideas? > > The reason I want this is to avoid extracting a tarball > over a directory that has files in it that are newer than > the tarball. > > Neither tar nor find seem to make this easy... What about this: test -n "`find . -type f -newer ../src.tar.gz`" && echo hi :-) > > * Alfred Perlstein [040716 00:15] wrote: > >>This adds a primary to find(1) "-exit ", it will cause >>find to exit(2) with the as the exit status. >> >>Useful for finding the first instance of something: >> >>find . -type f -newer ../src.tar.gz -exit 0 && echo hi >> >>this will make find abort with a zero exit status early upon >>finding a file newer than ../src.tar.gz. >> >>cvs diff: Diffing . >>Index: extern.h >>=================================================================== >>RCS file: /home/ncvs/src/usr.bin/find/extern.h,v >>retrieving revision 1.21 >>diff -u -r1.21 extern.h >>--- extern.h 28 May 2004 17:17:15 -0000 1.21 >>+++ extern.h 16 Jul 2004 07:07:50 -0000 >>@@ -58,6 +58,7 @@ >> creat_f c_depth; >> creat_f c_empty; >> creat_f c_exec; >>+creat_f c_exit; >> creat_f c_flags; >> creat_f c_follow; >> #if !defined(__NetBSD__) >>@@ -90,6 +91,7 @@ >> exec_f f_depth; >> exec_f f_empty; >> exec_f f_exec; >>+exec_f f_exit; >> exec_f f_expr; >> exec_f f_flags; >> exec_f f_fstype; >>Index: find.1 >>=================================================================== >>RCS file: /home/ncvs/src/usr.bin/find/find.1,v >>retrieving revision 1.66 >>diff -u -r1.66 find.1 >>--- find.1 7 Jul 2004 19:57:15 -0000 1.66 >>+++ find.1 16 Jul 2004 07:12:58 -0000 >>@@ -372,6 +372,10 @@ >> .Ar flags >> bits match those of >> .Ar notflags . >>+.It Ic -exit Ar exitstatus >>+This primary will cause the find program to exit immediately with an exit >>+status of >>+.Ar exitstatus . >> .It Ic -fstype Ar type >> True if the file is contained in a file system of type >> .Ar type . >>Index: function.c >>=================================================================== >>RCS file: /home/ncvs/src/usr.bin/find/function.c,v >>retrieving revision 1.50 >>diff -u -r1.50 function.c >>--- function.c 28 May 2004 17:17:15 -0000 1.50 >>+++ function.c 16 Jul 2004 07:07:05 -0000 >>@@ -748,6 +748,25 @@ >> } >> >> int >>+f_exit(PLAN *plan, FTSENT *entry) >>+{ >>+ >>+ exit(plan->flags); >>+} >>+ >>+PLAN * >>+c_exit(OPTION *option, char ***argvp) >>+{ >>+ PLAN *new; >>+ int ex; >>+ >>+ ex = atoi(nextarg(option, argvp)); >>+ new = palloc(option); >>+ new->flags = ex; >>+ return (new); >>+} >>+ >>+int >> f_flags(PLAN *plan, FTSENT *entry) >> { >> u_long flags; >>Index: option.c >>=================================================================== >>RCS file: /home/ncvs/src/usr.bin/find/option.c,v >>retrieving revision 1.22 >>diff -u -r1.22 option.c >>--- option.c 28 May 2004 17:17:15 -0000 1.22 >>+++ option.c 16 Jul 2004 07:06:49 -0000 >>@@ -76,6 +76,7 @@ >> { "-empty", c_empty, f_empty, 0 }, >> { "-exec", c_exec, f_exec, 0 }, >> { "-execdir", c_exec, f_exec, F_EXECDIR }, >>+ { "-exit", c_exit, f_exit, 0 }, >> { "-false", c_simple, f_not, 0 }, >> { "-flags", c_flags, f_flags, 0 }, >> { "-follow", c_follow, f_always_true, 0 }, >>-- >>- Alfred Perlstein >>- Research Engineering Development Inc. >>- email: bright@mu.org cell: 408-480-4684 > >