From 3444c77254126f63729ccee66523b2677ba0b51e Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Mon, 2 Nov 2009 11:29:03 -0500 Subject: [PATCH] Make the compiler/configure script idempotent. --- src/compiler/configure | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/compiler/configure b/src/compiler/configure index e7f57d023..c4e9ac5d6 100755 --- a/src/compiler/configure +++ b/src/compiler/configure @@ -42,11 +42,23 @@ while test $# -gt 0; do done MACHINE=`./choose-machine.sh "${MACHINE}"` -CMD="rm -f machine" -echo "${CMD}"; eval "${CMD}" +make_link () +{ + local target link + target="${1}" + link="${2}" + if [ -e "${link}" -a ! -L "${link}" ]; then + cat <&2 +${link} is not a symbolic link; refusing to clobber it. +EOF + exit 1 + else + CMDS="rm -f ${link} && ln -s ${target} ${link}" + echo "${CMDS}"; eval "${CMDS}" + fi +} -CMD="ln -s machines/${MACHINE} machine" -echo "${CMD}"; eval "${CMD}" +make_link "machines/${MACHINE}" machine LINKS="compiler.cbf compiler.pkg compiler.sf make.com" if test "${MACHINE}" = C; then @@ -54,8 +66,5 @@ if test "${MACHINE}" = C; then fi for FN in ${LINKS}; do - if [ ! -f "${FN}" ]; then - CMD="ln -s machine/${FN} ." - echo "${CMD}"; eval "${CMD}" - fi + make_link "machine/${FN}" "${FN}" done -- 2.25.1