upload.sh: Not all leading directories created

Bugfix in mkdir_ssh: Sometimes not all leading directories were
created.
This commit is contained in:
Jan Lindemann 2004-02-07 22:53:31 +00:00 committed by Jan Lindemann
commit 01b5f9c7c3

View file

@ -165,16 +165,17 @@ ssh_mkdir()
{ {
set -e set -e
dir=`echo $1 | sed -e 's/\/[^\/]*$//; s/\/*$//'` dir=`echo $1 | sed -e 's/\/[^\/]*$//; s/\/*$//'`
parts="/ `echo $dir | sed -e 's/\// /g'`" parts="/ `echo $dir | sed -e 's%/% %g'`"
test -n "$dir_mode" && MODE="-m $dir_mode" test -n "$dir_mode" && MODE="-m $dir_mode"
cat << EOT | cat << EOT |
echo creating $parts
for part in $parts; do for part in $parts; do
path="\$path/\$part" path="\$path/\$part"
if [ ! -d \$path ]; then if [ ! -d \$path ]; then
mkdir \$path || break mkdir \$path || break
test -n "$2" && chown "$2" \$path || break test -n "$2" && chown "$2" \$path || continue
test -n "$3" && chgrp "$3" \$path || break test -n "$3" && chgrp "$3" \$path || continue
test -n "$4" && chmod "$4" \$path || break test -n "$4" && chmod "$4" \$path || continue
fi fi
if [ ! -d \$path ]; then if [ ! -d \$path ]; then
echo "failed to create directory \$path, owner=\$file_owner, group=\$file_group, mode=\$dir_mode" echo "failed to create directory \$path, owner=\$file_owner, group=\$file_group, mode=\$dir_mode"