Added standard conform arithmetic $(()) instead of $[]

This commit is contained in:
Nico Schottelius 2006-01-22 12:21:35 +01:00
parent d7f1c71c9e
commit dd453a964a
2 changed files with 30 additions and 7 deletions

View file

@ -4,6 +4,7 @@
# Date: Mon Nov 14 11:45:11 CET 2005 # Date: Mon Nov 14 11:45:11 CET 2005
# Last Modified: (See ls -l or git) # Last Modified: (See ls -l or git)
echo hier8
# #
# where to find our configuration and temporary file # where to find our configuration and temporary file
# #
@ -34,6 +35,7 @@ add_name()
{ {
sed "s/^/\[$name\] /" sed "s/^/\[$name\] /"
} }
echo hier5
# #
# Tell how to use us # Tell how to use us
@ -57,6 +59,7 @@ usage()
exit 0 exit 0
} }
echo hier4
# #
# need at least intervall and one source or --all # need at least intervall and one source or --all
# #
@ -71,22 +74,23 @@ if [ ! -d "$CCOLLECT_CONF" ]; then
echo "Configuration \"$CCOLLECT_CONF\" not found." echo "Configuration \"$CCOLLECT_CONF\" not found."
exit 1 exit 1
fi fi
echo hier3
# #
# Filter arguments # Filter arguments
# #
INTERVALL=$1; shift INTERVALL=$1; shift
i=1 i=1
no_shares=0 no_shares=0
set -x
while [ $i -le $# ]; do while [ $i -le $# ]; do
eval arg=\$$i eval arg=\$$i
if [ "$NO_MORE_ARGS" = 1 ]; then if [ "$NO_MORE_ARGS" = 1 ]; then
eval share_${no_shares}=\"$arg\" eval share_${no_shares}=\"$arg\"
no_shares=$[$no_shares+1] no_shares=$(($no_shares+1))
else else
case $arg in case $arg in
-a|--all) -a|--all)
@ -106,12 +110,12 @@ while [ $i -le $# ]; do
;; ;;
*) *)
eval share_${no_shares}=\"$arg\" eval share_${no_shares}=\"$arg\"
no_shares=$[$no_shares+1] no_shares=$(($no_shares+1))
;; ;;
esac esac
fi fi
i=$[$i+1] i=$(($i+1))
done done
# #
@ -120,6 +124,7 @@ done
if [ "$VERBOSE" = 1 ]; then if [ "$VERBOSE" = 1 ]; then
set -x set -x
fi fi
echo hier4
# #
# Look, if we should take ALL sources # Look, if we should take ALL sources
@ -137,10 +142,11 @@ if [ "$ALL" = 1 ]; then
while read tmp; do while read tmp; do
eval share_${no_shares}=\"$tmp\" eval share_${no_shares}=\"$tmp\"
no_shares=$[$no_shares+1] no_shares=$(($no_shares+1))
done < "$TMP" done < "$TMP"
fi fi
echo hier6
# #
# Need at least ONE source to backup # Need at least ONE source to backup
# #
@ -174,7 +180,7 @@ while [ "$i" -lt "$no_shares" ]; do
# Get current share # Get current share
# #
eval name=\$share_${i} eval name=\$share_${i}
i=$[$i+1] i=$(($i+1))
export name export name
@ -206,6 +212,9 @@ while [ "$i" -lt "$no_shares" ]; do
c_vverbose="$backup/very_verbose" c_vverbose="$backup/very_verbose"
c_rsync_extra="$backup/rsync_options" c_rsync_extra="$backup/rsync_options"
c_pre_exec="$backup/pre_exec"
c_post_exec="$backup/post_exec"
echo "Beginning to backup this source ..." echo "Beginning to backup this source ..."
# #
@ -260,7 +269,14 @@ while [ "$i" -lt "$no_shares" ]; do
echo "Destination $c_dest does not link to a directory. Skipping" echo "Destination $c_dest does not link to a directory. Skipping"
exit 1 exit 1
fi fi
#
# pre_exec
#
if [ -x "$c_pre_exec" ]; then
"$pre_exec"
fi
# exclude # exclude
if [ -f "$c_exclude" ]; then if [ -f "$c_exclude" ]; then
EXCLUDE="--exclude-from=$c_exclude" EXCLUDE="--exclude-from=$c_exclude"
@ -346,6 +362,12 @@ while [ "$i" -lt "$no_shares" ]; do
fi fi
echo "Successfully finished backup." echo "Successfully finished backup."
#
# post_exec
#
if [ -x "$c_post_exec" ]; then
"$post_exec"
fi
) | add_name ) | add_name
done done

View file

@ -1,6 +1,7 @@
- implement pre- and post-exec commands - implement pre- and post-exec commands
o For the general backup process o For the general backup process
o source specific o source specific
o what to do with return values?
- Documentation - Documentation
- write/generate a manpage - write/generate a manpage