From 9efc8450ed3a65bd5216972c013be620444d3d50 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 8 Jan 2008 23:55:02 +0000 Subject: 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 --- nuttx/tools/link.sh | 27 +++++++++++++++------------ nuttx/tools/winlink.sh | 27 +++++++++++++++------------ 2 files changed, 30 insertions(+), 24 deletions(-) (limited to 'nuttx/tools') diff --git a/nuttx/tools/link.sh b/nuttx/tools/link.sh index 5c9576294..ef41b3314 100755 --- a/nuttx/tools/link.sh +++ b/nuttx/tools/link.sh @@ -33,6 +33,7 @@ # POSSIBILITY OF SUCH DAMAGE. # ############################################################################ +set -x src=$1 dest=$2 @@ -44,23 +45,25 @@ if [ -z "${src}" -o -z "${dest}" ]; then exit 1 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 - # replace it with the new link (which might be different) + # If the path exists and is a directory that contains the "fake link" + # mark, then treat it like a soft link (i.e., remove the directory) - if [ -h "${dest}" ]; then - rm -f "${dest}" + if [ -d "${dest}" -a -f "${dest}/.fakelnk" ]; then + rm -rf "${dest}" else - # If the path is a directory and contains the "fake link" mark, then - # treat it like a soft link (i.e., remove the directory) + # Does anything exist at the destination path? - if [ -d "${dest}" -a -f "${dest}/.fakelnk" ]; then - rm -rf "${dest}" - else + if [ -e "${dest}" ]; then # It is something else (like a file) or directory that does # not contain the "fake link" mark @@ -73,7 +76,7 @@ fi # Verify that a directory exists at the source path -if [ ! -d ${src} ]; then +if [ ! -d "${src}" ]; then echo "No directory at ${src}" exit 1 fi diff --git a/nuttx/tools/winlink.sh b/nuttx/tools/winlink.sh index c98efa47d..272fb9636 100755 --- a/nuttx/tools/winlink.sh +++ b/nuttx/tools/winlink.sh @@ -55,23 +55,25 @@ if [ -z "${src}" -o -z "${dest}" ]; then exit 1 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 - # replace it with the new directory copy + # If the path exists and is a directory that contains the "fake link" + # mark, then treat it like a soft link (i.e., remove the directory) - if [ -h "${dest}" ]; then - rm -f "${dest}" + if [ -d "${dest}" -a -f "${dest}/.fakelnk" ]; then + rm -rf "${dest}" else - # If the path is a directory and contains the "fake link" mark, then - # remove the directory so that we can replace it with a new copy + # Does anything exist at the destination path? - if [ -d "${dest}" -a -f "${dest}/.fakelnk" ]; then - rm -rf "${dest}" - else + if [ -e "${dest}" ]; then # It is something else (like a file) or directory that does # not contain the "fake link" mark @@ -82,9 +84,10 @@ if [ -e "${dest}" ]; then fi fi + # Verify that a directory exists at the source path -if [ ! -d ${src} ]; then +if [ ! -d "${src}" ]; then echo "No directory at ${src}" exit 1 fi -- cgit v1.2.3