From owner-freebsd-questions@FreeBSD.ORG Mon Jan 14 01:01:22 2013 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D9FF8643 for ; Mon, 14 Jan 2013 01:01:22 +0000 (UTC) (envelope-from freebsd-questions-local@be-well.ilk.org) Received: from asbnvacz-mailrelay01.megapath.net (asbnvacz-mailrelay01.megapath.net [207.145.128.243]) by mx1.freebsd.org (Postfix) with ESMTP id 89F96947 for ; Mon, 14 Jan 2013 01:01:22 +0000 (UTC) Received: from mail7.sea5.speakeasy.net (mail7.sea5.speakeasy.net [69.17.117.52]) by asbnvacz-mailrelay01.megapath.net (Postfix) with ESMTP id B7813A71084 for ; Sun, 13 Jan 2013 20:01:15 -0500 (EST) Received: (qmail 30995 invoked from network); 14 Jan 2013 01:01:15 -0000 Received: by simscan 1.4.0 ppid: 11259, pid: 29196, t: 1.3144s scanners: clamav: 0.88.2/m:52/d:13513 Received: from unknown (HELO be-well.ilk.org) ([66.92.78.145]) (envelope-sender ) by mail7.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 14 Jan 2013 01:01:13 -0000 Received: from lowell-desk.lan (lowell-desk.lan [172.30.250.8]) by be-well.ilk.org (Postfix) with ESMTP id 4275C33C1D; Sun, 13 Jan 2013 20:01:06 -0500 (EST) Received: by lowell-desk.lan (Postfix, from userid 1147) id 2DA3639829; Sun, 13 Jan 2013 20:01:06 -0500 (EST) From: Lowell Gilbert To: Fbsd8 Subject: Re: sh script problem with capturing return code References: <50EC9009.3030305@a1poweruser.com> <20130108224626.8c2d89cd.freebsd@edvax.de> <50EC99F2.3020404@a1poweruser.com> <44d2xevlhb.fsf@lowell-desk.lan> <50ED88CF.7060308@a1poweruser.com> <448v82unxb.fsf@lowell-desk.lan> <444niqum7n.fsf@lowell-desk.lan> <44zk0it6t5.fsf@lowell-desk.lan> <44r4ltu8zp.fsf@lowell-desk.lan> <50EE2604.4020809@a1poweruser.com> Date: Sun, 13 Jan 2013 20:01:06 -0500 In-Reply-To: <50EE2604.4020809@a1poweruser.com> (fbsd8@a1poweruser.com's message of "Wed, 09 Jan 2013 21:23:00 -0500") Message-ID: <44pq188tnx.fsf@lowell-desk.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain Cc: FreeBSD questions , Lowell Gilbert X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jan 2013 01:01:22 -0000 Fbsd8 writes: > Lowell Gilbert wrote: >> Lowell Gilbert writes: >> >>> I think it's a real bug, and the test cases don't cover "extra" elements >>> at all. Now I just have to figure out the right fix. >> >> I'm pretty sure that the fix is just to set rval on jumping to the >> "extra" tag in vwalk() in src/usr.sbin/mtree/verify.c. >> >> But my hot water heater just exploded, so I may not look at code for a >> few more days. > > Hello Lowell, > Thank you very much. > I was going crazy trying different combinations of options and script > logic. I want to thank you for taking my problem seriously and taking > the time to do your own test cases to verify my findings. Now that I > know it's a genuine bug in mtree, I can make my plans accordingly. Any > fix to the mtree utility will take some time to filter down to a > regular RELEASE. Maybe 9.2 or the big jump to 10.0 by the end of > 2013. I will leave it up to you the file a PR on this and follow > through. > Thanks again, people like you are what makes this questions list so > valuable and FreeBSD such a great OS. You did outstanding work. Actually, in retrospect I think it was pretty trivial. I think the following patch is the right fix for the problem, although I am not completely certain. ================================================================ Index: /usr/src/usr.sbin/mtree/verify.c =================================================================== --- /usr/src/usr.sbin/mtree/verify.c (revision 245177) +++ /usr/src/usr.sbin/mtree/verify.c (working copy) @@ -149,6 +149,7 @@ } (void)fts_set(t, p, FTS_SKIP); } + rval = MISMATCHEXIT; (void)fts_close(t); if (sflag) warnx("%s checksum: %lu", fullpath, (unsigned long)crc_total); ================================================================ This fixes the problem that was bothering you, but the interactions of different features are complicated, and many of them are documented in fairly loose language. Would you be interested in extending the test suite for this program? There are some tests in /usr/src/usr.sbin/mtree/test/, but they don't cover your issue. I'm particularly concerned with interactions between mtree(8) options like -u, -U, -q, -d, and specification keywords like "optional", "nochange", and "ignore". I would feel more comfortable if someone else wrote up new test cases (because programmers generally don't -- can't -- test their own blind spots), although I'll certainly do it if no one else does. I haven't submitted a PR yet, but I'll do so as soon as I've translated my test case into a form that can be used in the PR. [As an upside, I've learned about the fts_ family, which I hadn't really looked at before.] Be well.