From owner-freebsd-questions@FreeBSD.ORG Tue Jan 8 21:30:51 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 25627DDB for ; Tue, 8 Jan 2013 21:30:51 +0000 (UTC) (envelope-from fbsd8@a1poweruser.com) Received: from mail-03.name-services.com (mail-03.name-services.com [69.64.155.195]) by mx1.freebsd.org (Postfix) with ESMTP id 0B933CE4 for ; Tue, 8 Jan 2013 21:30:50 +0000 (UTC) Received: from [10.0.10.3] ([173.88.197.103]) by mail-03.name-services.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 8 Jan 2013 13:30:51 -0800 Message-ID: <50EC9009.3030305@a1poweruser.com> Date: Tue, 08 Jan 2013 16:30:49 -0500 From: Fbsd8 User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: FreeBSD questions Subject: sh script problem with capturing return code Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 08 Jan 2013 21:30:51.0522 (UTC) FILETIME=[6EC49E20:01CDEDE7] X-Sender: fbsd8@a1poweruser.com X-Authenticated-Sender: fbsd8@a1poweruser.com X-EchoSenderHash: [fbsd8]-[a1poweruser*com] 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: Tue, 08 Jan 2013 21:30:51 -0000 I can not get the return code from mtree to control the displaying of a error message. The mtree at the end of the script does function correctly because I can tell from the printed output. When mtree prints comments saying "extra" that means the directory being read does not match the specification file. return code should be Not equal to zero. And when they do match IE: no mtree comments printed, that should be a return code of zero. I tried 2 different ways to capture the return code to no joy. What I am doing wrong? #! /bin/sh flavor="/a/mtree.std" echo "flavor = ${flavor}" /bin/cat << EOF | /set type=dir uname=root gname=wheel . etc ignore .. root ignore .. usr home ignore .. local etc ignore .. .. .. .. EOF mtree -d -u -p "${flavor}" || \ echo "Error invalid directories in flavor ${flavor}." #mtree -d -p "${flavor}" #[ $? -eq 0 ] || \ # echo "Error invalid directories in flavor ${flavor}." echo "return = $?"