xref: /titanic_51/usr/src/cmd/ast/libshell/common/scripts/simplefileattributetree1.sh (revision b4dd7d09880f14016feece03929a224eca1cf39a)
1*b4dd7d09SAndy Fiddaman#!/usr/bin/ksh93
2*b4dd7d09SAndy Fiddaman
3*b4dd7d09SAndy Fiddaman#
4*b4dd7d09SAndy Fiddaman# CDDL HEADER START
5*b4dd7d09SAndy Fiddaman#
6*b4dd7d09SAndy Fiddaman# The contents of this file are subject to the terms of the
7*b4dd7d09SAndy Fiddaman# Common Development and Distribution License (the "License").
8*b4dd7d09SAndy Fiddaman# You may not use this file except in compliance with the License.
9*b4dd7d09SAndy Fiddaman#
10*b4dd7d09SAndy Fiddaman# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11*b4dd7d09SAndy Fiddaman# or http://www.opensolaris.org/os/licensing.
12*b4dd7d09SAndy Fiddaman# See the License for the specific language governing permissions
13*b4dd7d09SAndy Fiddaman# and limitations under the License.
14*b4dd7d09SAndy Fiddaman#
15*b4dd7d09SAndy Fiddaman# When distributing Covered Code, include this CDDL HEADER in each
16*b4dd7d09SAndy Fiddaman# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17*b4dd7d09SAndy Fiddaman# If applicable, add the following below this CDDL HEADER, with the
18*b4dd7d09SAndy Fiddaman# fields enclosed by brackets "[]" replaced with your own identifying
19*b4dd7d09SAndy Fiddaman# information: Portions Copyright [yyyy] [name of copyright owner]
20*b4dd7d09SAndy Fiddaman#
21*b4dd7d09SAndy Fiddaman# CDDL HEADER END
22*b4dd7d09SAndy Fiddaman#
23*b4dd7d09SAndy Fiddaman
24*b4dd7d09SAndy Fiddaman#
25*b4dd7d09SAndy Fiddaman# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
26*b4dd7d09SAndy Fiddaman#
27*b4dd7d09SAndy Fiddaman
28*b4dd7d09SAndy Fiddaman#
29*b4dd7d09SAndy Fiddaman# simplefileattributetree1 - build a simple file tree (including file attributes)
30*b4dd7d09SAndy Fiddaman#
31*b4dd7d09SAndy Fiddaman
32*b4dd7d09SAndy Fiddaman# Solaris needs /usr/xpg6/bin:/usr/xpg4/bin because the tools in /usr/bin are not POSIX-conformant
33*b4dd7d09SAndy Fiddamanexport PATH=/usr/xpg6/bin:/usr/xpg4/bin:/bin:/usr/bin
34*b4dd7d09SAndy Fiddaman
35*b4dd7d09SAndy Fiddaman# Make sure all math stuff runs in the "C" locale to avoid problems
36*b4dd7d09SAndy Fiddaman# with alternative # radix point representations (e.g. ',' instead of
37*b4dd7d09SAndy Fiddaman# '.' in de_DE.*-locales). This needs to be set _before_ any
38*b4dd7d09SAndy Fiddaman# floating-point constants are defined in this script).
39*b4dd7d09SAndy Fiddamanif [[ "${LC_ALL}" != "" ]] ; then
40*b4dd7d09SAndy Fiddaman    export \
41*b4dd7d09SAndy Fiddaman        LC_MONETARY="${LC_ALL}" \
42*b4dd7d09SAndy Fiddaman        LC_MESSAGES="${LC_ALL}" \
43*b4dd7d09SAndy Fiddaman        LC_COLLATE="${LC_ALL}" \
44*b4dd7d09SAndy Fiddaman        LC_CTYPE="${LC_ALL}"
45*b4dd7d09SAndy Fiddaman        unset LC_ALL
46*b4dd7d09SAndy Fiddamanfi
47*b4dd7d09SAndy Fiddamanexport LC_NUMERIC=C
48*b4dd7d09SAndy Fiddaman
49*b4dd7d09SAndy Fiddaman
50*b4dd7d09SAndy Fiddamanfunction add_file_to_tree
51*b4dd7d09SAndy Fiddaman{
52*b4dd7d09SAndy Fiddaman	typeset treename=$1
53*b4dd7d09SAndy Fiddaman	typeset filename=$2
54*b4dd7d09SAndy Fiddaman	nameref destnodename=$3
55*b4dd7d09SAndy Fiddaman	integer i
56*b4dd7d09SAndy Fiddaman	typeset nodepath # full name of compound variable
57*b4dd7d09SAndy Fiddaman	typeset -a pe # path elements
58*b4dd7d09SAndy Fiddaman
59*b4dd7d09SAndy Fiddaman	# first built an array containing the names of each path element
60*b4dd7d09SAndy Fiddaman	# (e.g. "foo/var/baz"" results in an array containing "( 'foo' 'bar' 'baz' )")
61*b4dd7d09SAndy Fiddaman	typeset IFS='/'
62*b4dd7d09SAndy Fiddaman	pe+=( ${filename} )
63*b4dd7d09SAndy Fiddaman
64*b4dd7d09SAndy Fiddaman	[[ ${pe[0]} == '' ]] && pe[0]='/'
65*b4dd7d09SAndy Fiddaman
66*b4dd7d09SAndy Fiddaman	# walk path described via the "pe" array and build nodes if
67*b4dd7d09SAndy Fiddaman	# there aren't any nodes yet
68*b4dd7d09SAndy Fiddaman	nodepath="${treename}"
69*b4dd7d09SAndy Fiddaman	for (( i=0 ; i < (${#pe[@]}-1) ; i++ )) ; do
70*b4dd7d09SAndy Fiddaman		nameref x="${nodepath}"
71*b4dd7d09SAndy Fiddaman
72*b4dd7d09SAndy Fiddaman		# [[ -v ]] does not work for arrays because [[ -v ar ]]
73*b4dd7d09SAndy Fiddaman		# is equal to [[ -v ar[0] ]]. In this case we can
74*b4dd7d09SAndy Fiddaman		# use the output of typeset +p x.nodes
75*b4dd7d09SAndy Fiddaman		[[ "${ typeset +p x.nodes ; }" == "" ]] && compound -A x.nodes
76*b4dd7d09SAndy Fiddaman
77*b4dd7d09SAndy Fiddaman		nodepath+=".nodes[${pe[i]}]"
78*b4dd7d09SAndy Fiddaman	done
79*b4dd7d09SAndy Fiddaman
80*b4dd7d09SAndy Fiddaman	# insert element
81*b4dd7d09SAndy Fiddaman	nameref node="${nodepath}"
82*b4dd7d09SAndy Fiddaman	[[ "${ typeset +p node.elements ; }" == "" ]] && compound -A node.elements
83*b4dd7d09SAndy Fiddaman	node.elements[${pe[i]}]=(
84*b4dd7d09SAndy Fiddaman		filepath="${filename}"
85*b4dd7d09SAndy Fiddaman	)
86*b4dd7d09SAndy Fiddaman
87*b4dd7d09SAndy Fiddaman	destnodename="${!node}.elements[${pe[i]}]"
88*b4dd7d09SAndy Fiddaman
89*b4dd7d09SAndy Fiddaman	return 0
90*b4dd7d09SAndy Fiddaman}
91*b4dd7d09SAndy Fiddaman
92*b4dd7d09SAndy Fiddamanfunction parse_findls
93*b4dd7d09SAndy Fiddaman{
94*b4dd7d09SAndy Fiddaman	nameref out=$1
95*b4dd7d09SAndy Fiddaman	typeset str="$2"
96*b4dd7d09SAndy Fiddaman
97*b4dd7d09SAndy Fiddaman	# find -ls on Solaris uses the following output format by default:
98*b4dd7d09SAndy Fiddaman	#604302    3 -rw-r--r--   1 test001  users        2678 May  9 00:46 ./httpsresdump
99*b4dd7d09SAndy Fiddaman
100*b4dd7d09SAndy Fiddaman	integer out.inodenum="${str/~(Elr)[[:space:]]*([[:digit:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]-]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]]*[[:space:]]+[[:digit:]]*[[:space:]]+[[:digit:]:]+)[[:space:]]+(.+)/\1}"
101*b4dd7d09SAndy Fiddaman	integer out.kbblocks="${str/~(Elr)[[:space:]]*([[:digit:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]-]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]]*[[:space:]]+[[:digit:]]*[[:space:]]+[[:digit:]:]+)[[:space:]]+(.+)/\2}"
102*b4dd7d09SAndy Fiddaman	typeset out.mode="${str/~(Elr)[[:space:]]*([[:digit:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]-]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]]*[[:space:]]+[[:digit:]]*[[:space:]]+[[:digit:]:]+)[[:space:]]+(.+)/\3}"
103*b4dd7d09SAndy Fiddaman	integer out.numlinks="${str/~(Elr)[[:space:]]*([[:digit:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]-]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]]*[[:space:]]+[[:digit:]]*[[:space:]]+[[:digit:]:]+)[[:space:]]+(.+)/\4}"
104*b4dd7d09SAndy Fiddaman	compound out.owner=(
105*b4dd7d09SAndy Fiddaman		typeset user="${str/~(Elr)[[:space:]]*([[:digit:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]-]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]]*[[:space:]]+[[:digit:]]*[[:space:]]+[[:digit:]:]+)[[:space:]]+(.+)/\5}"
106*b4dd7d09SAndy Fiddaman		typeset group="${str/~(Elr)[[:space:]]*([[:digit:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]-]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]]*[[:space:]]+[[:digit:]]*[[:space:]]+[[:digit:]:]+)[[:space:]]+(.+)/\6}"
107*b4dd7d09SAndy Fiddaman	)
108*b4dd7d09SAndy Fiddaman	integer out.filesize="${str/~(Elr)[[:space:]]*([[:digit:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]-]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]]*[[:space:]]+[[:digit:]]*[[:space:]]+[[:digit:]:]+)[[:space:]]+(.+)/\7}"
109*b4dd7d09SAndy Fiddaman	typeset out.date="${str/~(Elr)[[:space:]]*([[:digit:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]-]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]]*[[:space:]]+[[:digit:]]*[[:space:]]+[[:digit:]:]+)[[:space:]]+(.+)/\8}"
110*b4dd7d09SAndy Fiddaman	typeset out.filepath="${str/~(Elr)[[:space:]]*([[:digit:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]-]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:alnum:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]]*[[:space:]]+[[:digit:]]*[[:space:]]+[[:digit:]:]+)[[:space:]]+(.+)/\9}"
111*b4dd7d09SAndy Fiddaman
112*b4dd7d09SAndy Fiddaman	return 0
113*b4dd7d09SAndy Fiddaman}
114*b4dd7d09SAndy Fiddaman
115*b4dd7d09SAndy Fiddamanfunction usage
116*b4dd7d09SAndy Fiddaman{
117*b4dd7d09SAndy Fiddaman	OPTIND=0
118*b4dd7d09SAndy Fiddaman	getopts -a "${progname}" "${simplefileattributetree1_usage}" OPT '-?'
119*b4dd7d09SAndy Fiddaman	exit 2
120*b4dd7d09SAndy Fiddaman}
121*b4dd7d09SAndy Fiddaman
122*b4dd7d09SAndy Fiddaman# main
123*b4dd7d09SAndy Fiddamanbuiltin basename
124*b4dd7d09SAndy Fiddamanbuiltin dirname
125*b4dd7d09SAndy Fiddaman
126*b4dd7d09SAndy Fiddamanset -o noglob
127*b4dd7d09SAndy Fiddamanset -o nounset
128*b4dd7d09SAndy Fiddaman
129*b4dd7d09SAndy Fiddaman# tree base
130*b4dd7d09SAndy Fiddamancompound filetree
131*b4dd7d09SAndy Fiddaman
132*b4dd7d09SAndy Fiddaman# benchmark data
133*b4dd7d09SAndy Fiddamancompound bench=(
134*b4dd7d09SAndy Fiddaman	float start
135*b4dd7d09SAndy Fiddaman	float stop
136*b4dd7d09SAndy Fiddaman)
137*b4dd7d09SAndy Fiddaman
138*b4dd7d09SAndy Fiddamancompound appconfig=(
139*b4dd7d09SAndy Fiddaman	typeset do_benchmarking=false
140*b4dd7d09SAndy Fiddaman	compound do_record=(
141*b4dd7d09SAndy Fiddaman		typeset content=false
142*b4dd7d09SAndy Fiddaman		typeset filetype=false
143*b4dd7d09SAndy Fiddaman	)
144*b4dd7d09SAndy Fiddaman)
145*b4dd7d09SAndy Fiddaman
146*b4dd7d09SAndy Fiddaman
147*b4dd7d09SAndy Fiddamaninteger i
148*b4dd7d09SAndy Fiddaman
149*b4dd7d09SAndy Fiddamantypeset progname="${ basename "${0}" ; }"
150*b4dd7d09SAndy Fiddaman
151*b4dd7d09SAndy Fiddamantypeset -r simplefileattributetree1_usage=$'+
152*b4dd7d09SAndy Fiddaman[-?\n@(#)\$Id: simplefileattributetree1 (Roland Mainz) 2010-03-27 \$\n]
153*b4dd7d09SAndy Fiddaman[-author?Roland Mainz <roland.mainz@nrubsig.org>]
154*b4dd7d09SAndy Fiddaman[+NAME?simplefileattributetree1 - generate compound variable tree which contains file names and their attributes]
155*b4dd7d09SAndy Fiddaman[+DESCRIPTION?\bsimplefileattributetree1\b is a simple variable tree
156*b4dd7d09SAndy Fiddaman	demo which builds a compound variable tree based on the output
157*b4dd7d09SAndy Fiddaman	of /usr/xpg4/bin/file which contains the file name, the file attributes
158*b4dd7d09SAndy Fiddaman	and optionally file type and content]
159*b4dd7d09SAndy Fiddaman[b:benchmark?Print time needed to generate the tree.]
160*b4dd7d09SAndy Fiddaman[c:includecontent?Include the file\'s content in the tree, split into 1kb blocks.]
161*b4dd7d09SAndy Fiddaman[t:includefiletype?Include the file type (output of /usr/xpg4/bin/file).]
162*b4dd7d09SAndy Fiddaman
163*b4dd7d09SAndy Fiddamanpath
164*b4dd7d09SAndy Fiddaman
165*b4dd7d09SAndy Fiddaman[+SEE ALSO?\bksh93\b(1), \bfile\b(1), \bfind\b(1)]
166*b4dd7d09SAndy Fiddaman'
167*b4dd7d09SAndy Fiddaman
168*b4dd7d09SAndy Fiddamanwhile getopts -a "${progname}" "${simplefileattributetree1_usage}" OPT ; do
169*b4dd7d09SAndy Fiddaman#	printmsg "## OPT=|${OPT}|, OPTARG=|${OPTARG}|"
170*b4dd7d09SAndy Fiddaman	case ${OPT} in
171*b4dd7d09SAndy Fiddaman		b)	appconfig.do_benchmarking="true"	;;
172*b4dd7d09SAndy Fiddaman		+b)	appconfig.do_benchmarking="false"	;;
173*b4dd7d09SAndy Fiddaman		c)	appconfig.do_record.content="true"	;;
174*b4dd7d09SAndy Fiddaman		+c)	appconfig.do_record.content="false"	;;
175*b4dd7d09SAndy Fiddaman		t)	appconfig.do_record.filetype="true"	;;
176*b4dd7d09SAndy Fiddaman		+t)	appconfig.do_record.filetype="false"	;;
177*b4dd7d09SAndy Fiddaman		*)	usage ;;
178*b4dd7d09SAndy Fiddaman	esac
179*b4dd7d09SAndy Fiddamandone
180*b4dd7d09SAndy Fiddamanshift $((OPTIND-1))
181*b4dd7d09SAndy Fiddaman
182*b4dd7d09SAndy Fiddaman
183*b4dd7d09SAndy Fiddaman# argument prechecks
184*b4dd7d09SAndy Fiddamanif (( $# == 0 )) ; then
185*b4dd7d09SAndy Fiddaman	print -u2 -f "%s: Missing <path> argument.\n" "${progname}"
186*b4dd7d09SAndy Fiddaman	exit 1
187*b4dd7d09SAndy Fiddamanfi
188*b4dd7d09SAndy Fiddaman
189*b4dd7d09SAndy Fiddaman
190*b4dd7d09SAndy Fiddamanprint -u2 -f "# reading file names...\n"
191*b4dd7d09SAndy Fiddamanwhile (( $# > 0 )) ; do
192*b4dd7d09SAndy Fiddaman	# "ulimit -c 0" use used to force ksh93 to use a seperate process for subshells,
193*b4dd7d09SAndy Fiddaman	# this is used to work around a bug with LC_ALL changes bleeding through subshells
194*b4dd7d09SAndy Fiddaman	IFS=$'\n' ; typeset -a findls_lines=( $(ulimit -c 0 ; LC_ALL=C find "$1" -type f -ls) ) ; IFS=$' \t\n'
195*b4dd7d09SAndy Fiddaman	shift
196*b4dd7d09SAndy Fiddamandone
197*b4dd7d09SAndy Fiddaman
198*b4dd7d09SAndy Fiddaman
199*b4dd7d09SAndy Fiddamanprint -u2 -f "# building tree...\n"
200*b4dd7d09SAndy Fiddaman
201*b4dd7d09SAndy Fiddaman${appconfig.do_benchmarking} && (( bench.start=SECONDS ))
202*b4dd7d09SAndy Fiddaman
203*b4dd7d09SAndy Fiddamanfor (( i=0 ; i < ${#findls_lines[@]} ; i++ )) ; do
204*b4dd7d09SAndy Fiddaman	compound parseddata
205*b4dd7d09SAndy Fiddaman	typeset treenodename
206*b4dd7d09SAndy Fiddaman
207*b4dd7d09SAndy Fiddaman	# parse "find -ls" output
208*b4dd7d09SAndy Fiddaman	parse_findls parseddata "${findls_lines[i]}"
209*b4dd7d09SAndy Fiddaman
210*b4dd7d09SAndy Fiddaman	# add node to tree and return it's absolute name in "treenodename"
211*b4dd7d09SAndy Fiddaman	add_file_to_tree filetree "${parseddata.filepath}" treenodename
212*b4dd7d09SAndy Fiddaman
213*b4dd7d09SAndy Fiddaman	# merge parsed "find -ls" output into tree node
214*b4dd7d09SAndy Fiddaman	nameref treenode="${treenodename}"
215*b4dd7d09SAndy Fiddaman	treenode+=parseddata
216*b4dd7d09SAndy Fiddaman
217*b4dd7d09SAndy Fiddaman	# extras (calculated from the existing values in "parseddata")
218*b4dd7d09SAndy Fiddaman	typeset treenode.dirname="${ dirname "${treenode.filepath}" ; }"
219*b4dd7d09SAndy Fiddaman	typeset treenode.basename="${ basename "${treenode.filepath}" ; }"
220*b4dd7d09SAndy Fiddaman
221*b4dd7d09SAndy Fiddaman	if ${appconfig.do_record.filetype} ; then
222*b4dd7d09SAndy Fiddaman		# Using /usr/(xpg4/)*/bin/file requires a |fork()|+|exec()| which makes the script a few hundred times slower... ;-(
223*b4dd7d09SAndy Fiddaman		typeset treenode.filetype="$(file "${treenode.filepath}")"
224*b4dd7d09SAndy Fiddaman	fi
225*b4dd7d09SAndy Fiddaman
226*b4dd7d09SAndy Fiddaman	if ${appconfig.do_record.content} ; then
227*b4dd7d09SAndy Fiddaman		if [[ -r "${treenode.filepath}" ]] ; then
228*b4dd7d09SAndy Fiddaman			# We use an array of compound variables here to support
229*b4dd7d09SAndy Fiddaman			# files with holes (and later alternative streams, too)
230*b4dd7d09SAndy Fiddaman			compound -a treenode.content
231*b4dd7d09SAndy Fiddaman			integer cl=0
232*b4dd7d09SAndy Fiddaman			while \
233*b4dd7d09SAndy Fiddaman				{
234*b4dd7d09SAndy Fiddaman					treenode.content[${cl}]=(
235*b4dd7d09SAndy Fiddaman						typeset type="data" # (todo: "add support for "holes" (sparse files))
236*b4dd7d09SAndy Fiddaman						typeset -b bin
237*b4dd7d09SAndy Fiddaman					)
238*b4dd7d09SAndy Fiddaman					read -n1024 treenode.content[${cl}].bin
239*b4dd7d09SAndy Fiddaman				} ; do
240*b4dd7d09SAndy Fiddaman				(( cl++ ))
241*b4dd7d09SAndy Fiddaman			done < "${treenode.filepath}"
242*b4dd7d09SAndy Fiddaman			unset treenode.content[${cl}]
243*b4dd7d09SAndy Fiddaman
244*b4dd7d09SAndy Fiddaman			typeset -A treenode.hashsum=(
245*b4dd7d09SAndy Fiddaman				[md5]="$(sum -x md5 < "${treenode.filepath}")"
246*b4dd7d09SAndy Fiddaman				[sha512]="$(sum -x sha512 < "${treenode.filepath}")"
247*b4dd7d09SAndy Fiddaman			)
248*b4dd7d09SAndy Fiddaman
249*b4dd7d09SAndy Fiddaman			# we do this for internal debugging only
250*b4dd7d09SAndy Fiddaman			if [[ "${ {
251*b4dd7d09SAndy Fiddaman					integer j
252*b4dd7d09SAndy Fiddaman					for (( j=0 ; j < ${#treenode.content[@]} ; j++ )) ; do
253*b4dd7d09SAndy Fiddaman						printf "%B" treenode.content[$j].bin
254*b4dd7d09SAndy Fiddaman					done
255*b4dd7d09SAndy Fiddaman				} | sum -x sha512 ; }" != "${treenode.hashsum[sha512]}" ]] ; then
256*b4dd7d09SAndy Fiddaman				# this should never happen...
257*b4dd7d09SAndy Fiddaman				print -u2 -f "fatal hash mismatch for %s\n" "${treenode.filepath}"
258*b4dd7d09SAndy Fiddaman				unset treenode.content treenode.hashsum
259*b4dd7d09SAndy Fiddaman			fi
260*b4dd7d09SAndy Fiddaman		fi
261*b4dd7d09SAndy Fiddaman	fi
262*b4dd7d09SAndy Fiddamandone
263*b4dd7d09SAndy Fiddaman
264*b4dd7d09SAndy Fiddaman${appconfig.do_benchmarking} && (( bench.stop=SECONDS ))
265*b4dd7d09SAndy Fiddaman
266*b4dd7d09SAndy Fiddaman
267*b4dd7d09SAndy Fiddamanif ${appconfig.do_benchmarking} ; then
268*b4dd7d09SAndy Fiddaman	# print benchmark data
269*b4dd7d09SAndy Fiddaman	print -u2 -f "# time used: %f\n" $((bench.stop - bench.start))
270*b4dd7d09SAndy Fiddamanfi
271*b4dd7d09SAndy Fiddaman
272*b4dd7d09SAndy Fiddaman# print variable tree
273*b4dd7d09SAndy Fiddamanprint -v filetree
274*b4dd7d09SAndy Fiddaman
275*b4dd7d09SAndy Fiddamanexit 0
276*b4dd7d09SAndy Fiddaman# EOF.
277