sh script problem with capturing return code
Lowell Gilbert
freebsd-questions-local at be-well.ilk.org
Wed Jan 9 20:00:40 UTC 2013
Fbsd8 <fbsd8 at a1poweruser.com> writes:
> So the question remains, why is mtree giving a return of zero when it
> finds directories on the target that are not in the spec file?
Okay, I had a hard time figuring out your examples, but I think I've got
an independent repeatable test case for the problem.
================================================================
mkdir etc home
mtree -c -d > ../out
mtree -d < ../out
echo $?
mkdir home/temp
mtree -d < ../out
echo $?
sed -i "" 's/^\(home[ ]*\)\(.*\)$/\1ignore/' ../out
mtree -d < ../out
echo $?
================================================================
The results are:
================================================================
5045] (lowell-desk) temp> mkdir etc home
[5046] (lowell-desk) temp> mtree -c -d > ../out
[5047] (lowell-desk) temp> mtree -d < ../out
[5048] (lowell-desk) temp> echo $?
0
[5049] (lowell-desk) temp> mkdir home/temp
[5050] (lowell-desk) temp> mtree -d < ../out
home/temp extra
[5051] (lowell-desk) temp> echo $?
0
[5052] (lowell-desk) temp> sed -i "" 's/^\(home[ ]*\)\(.*\)$/\1ignore/' ../out
[5053] (lowell-desk) temp> mtree -d < ../out
[5054] (lowell-desk) temp> echo $?
0
================================================================
and I think the problem you're having is that the second "echo $?"
should be 2, although the others are correct at 0. Is that correct?
One difference from your example is that you're using '-u'. I'm not sure
why you're doing that, but it doesn't affect the bug.
Yours,
Lowell
--
http://be-well.ilk.org/~lowell/
More information about the freebsd-questions
mailing list