upload.sh: Fix uploading multiple sources, was completely broken

This commit is contained in:
Jan Lindemann 2004-02-08 12:11:15 +00:00 committed by Jan Lindemann
commit 2e94ebe232

View file

@ -148,7 +148,7 @@ parse_target()
test -n "$FILE_GROUP" && echo file_group="\"$FILE_GROUP\";"
if is_dir "$target_file" ; then
echo target_path=\"$TARGET_FILE/`basename $source`\" # TODO: this is bullshit
echo target_path=\"$TARGET_FILE/`basename $TARGET_FILE`\" # TODO: this is bullshit
else
echo target_path=\"$TARGET_FILE\" # TODO: this is bullshit
fi
@ -237,13 +237,21 @@ shift
test -z "$VARIABLE" && test $# -lt 2 && usage 1
# -- get parameters from command line
source=$1
shift
n_targets=`expr $# - 1`
target="`echo $* | cut -d' ' -f$#`"
source="`echo $* | cut -d' ' -f1-$n_targets`"
#echo target=$target
#echo source=$source
# -- check run
for t in $*; do
# parse_target $t
eval `parse_target $t`
for s in $source; do
if [ ! -d "$s" -a ! -f "$s" -a ! -L "$s" ]; then
echo \"$s\" is neither a regular file, nor a directory, nor a link. Exiting. >&2
exit 1
fi
done
eval `parse_target $target`
if [ "$PARSE_TARGET" != OK ]; then
echo "Failed to parse target \"$t\"; exiting."
parse_target $t
@ -256,16 +264,11 @@ for t in $*; do
echo "File owner \"$file_owner\" is only legal, if you log in as \"$login\" or as \"root\"."
exit 1
fi
fi
if [ ! -d "$source" -a ! -f "$source" -a ! -L "$source" ]; then
echo \"$source\" is neither a regular file, nor a directory, nor a link. Exiting. >&2
exit 1
fi;;
*)
echo "Support for method \"$method\" is not implemented." >&2
exit 1;;
esac
done
# -- real run
if [ -n "$VARIABLE" ]; then
@ -298,8 +301,7 @@ if [ "$PARSE" = 1 ]; then
test "$EXIT" = 1 && exit 0
fi
for t in $*; do
eval `parse_target $t`
eval `parse_target $target`
case $method in
rsync_ssh)
ssh_mkdir $target_file $file_owner $file_group $dir_mode || break
@ -311,5 +313,4 @@ for t in $*; do
echo "Internal error: \"$method\" is not implemented." >&2
exit 1;;
esac
done