mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
Need to handle paths with spaces in them
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@532 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
+15
-12
@@ -33,6 +33,7 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
set -x
|
||||||
|
|
||||||
src=$1
|
src=$1
|
||||||
dest=$2
|
dest=$2
|
||||||
@@ -44,23 +45,25 @@ if [ -z "${src}" -o -z "${dest}" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if something already exists at the destination path
|
# Check if something already exists at the destination path replace it with
|
||||||
|
# the new link (which might be different). Note that we check for the
|
||||||
|
# the link (-h) before we check for existence (-e) because a bad link will
|
||||||
|
# report that it does not exist.
|
||||||
|
|
||||||
if [ -e "${dest}" ]; then
|
if [ -h "${dest}" ]; then
|
||||||
|
rm -f "${dest}"
|
||||||
|
else
|
||||||
|
|
||||||
# Yes, is it a symbolic link? If so, then remove it so that we can
|
# If the path exists and is a directory that contains the "fake link"
|
||||||
# replace it with the new link (which might be different)
|
# mark, then treat it like a soft link (i.e., remove the directory)
|
||||||
|
|
||||||
if [ -h "${dest}" ]; then
|
if [ -d "${dest}" -a -f "${dest}/.fakelnk" ]; then
|
||||||
rm -f "${dest}"
|
rm -rf "${dest}"
|
||||||
else
|
else
|
||||||
|
|
||||||
# If the path is a directory and contains the "fake link" mark, then
|
# Does anything exist at the destination path?
|
||||||
# treat it like a soft link (i.e., remove the directory)
|
|
||||||
|
|
||||||
if [ -d "${dest}" -a -f "${dest}/.fakelnk" ]; then
|
if [ -e "${dest}" ]; then
|
||||||
rm -rf "${dest}"
|
|
||||||
else
|
|
||||||
|
|
||||||
# It is something else (like a file) or directory that does
|
# It is something else (like a file) or directory that does
|
||||||
# not contain the "fake link" mark
|
# not contain the "fake link" mark
|
||||||
@@ -73,7 +76,7 @@ fi
|
|||||||
|
|
||||||
# Verify that a directory exists at the source path
|
# Verify that a directory exists at the source path
|
||||||
|
|
||||||
if [ ! -d ${src} ]; then
|
if [ ! -d "${src}" ]; then
|
||||||
echo "No directory at ${src}"
|
echo "No directory at ${src}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
+15
-12
@@ -55,23 +55,25 @@ if [ -z "${src}" -o -z "${dest}" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if something already exists at the destination path
|
# Check if something already exists at the destination path replace it with
|
||||||
|
# the new link (which might be different). Note that we check for the
|
||||||
|
# the link (-h) before we check for existence (-e) because a bad link will
|
||||||
|
# report that it does not exist.
|
||||||
|
|
||||||
if [ -e "${dest}" ]; then
|
if [ -h "${dest}" ]; then
|
||||||
|
rm -f "${dest}"
|
||||||
|
else
|
||||||
|
|
||||||
# Yes, is it a symbolic link? If so, then remove it so that we can
|
# If the path exists and is a directory that contains the "fake link"
|
||||||
# replace it with the new directory copy
|
# mark, then treat it like a soft link (i.e., remove the directory)
|
||||||
|
|
||||||
if [ -h "${dest}" ]; then
|
if [ -d "${dest}" -a -f "${dest}/.fakelnk" ]; then
|
||||||
rm -f "${dest}"
|
rm -rf "${dest}"
|
||||||
else
|
else
|
||||||
|
|
||||||
# If the path is a directory and contains the "fake link" mark, then
|
# Does anything exist at the destination path?
|
||||||
# remove the directory so that we can replace it with a new copy
|
|
||||||
|
|
||||||
if [ -d "${dest}" -a -f "${dest}/.fakelnk" ]; then
|
if [ -e "${dest}" ]; then
|
||||||
rm -rf "${dest}"
|
|
||||||
else
|
|
||||||
|
|
||||||
# It is something else (like a file) or directory that does
|
# It is something else (like a file) or directory that does
|
||||||
# not contain the "fake link" mark
|
# not contain the "fake link" mark
|
||||||
@@ -82,9 +84,10 @@ if [ -e "${dest}" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Verify that a directory exists at the source path
|
# Verify that a directory exists at the source path
|
||||||
|
|
||||||
if [ ! -d ${src} ]; then
|
if [ ! -d "${src}" ]; then
|
||||||
echo "No directory at ${src}"
|
echo "No directory at ${src}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user