Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 08 Jan 2013 16:30:49 -0500
From:      Fbsd8 <fbsd8@a1poweruser.com>
To:        FreeBSD questions <questions@freebsd.org>
Subject:   sh script problem with capturing return code
Message-ID:  <50EC9009.3030305@a1poweruser.com>

next in thread | raw e-mail | index | archive | help

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 = $?"





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50EC9009.3030305>