From 8fe72c159afb5cc235325d943e0d2875ac85fdf6 Mon Sep 17 00:00:00 2001 From: abscondment Date: Fri, 12 Feb 2010 14:04:47 -0800 Subject: [PATCH] Refining upgrade: check for access, request confirmation. --- bin/lein | 28 +++++++++++++++++++++------- src/leiningen/upgrade.clj | 4 +++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/bin/lein b/bin/lein index 4eefa671..f3fb62b0 100755 --- a/bin/lein +++ b/bin/lein @@ -86,13 +86,27 @@ elif [ "$1" = "upgrade" ]; then echo "See the \"Hacking\" section of the README." exit 1 fi - echo "Upgrading Leiningen now..." - LEIN_SCRIPT_URL="http://github.com/technomancy/leiningen/raw/stable/bin/lein" - $HTTP_CLIENT "$SCRIPT" "$LEIN_SCRIPT_URL" \ - && chmod +x "$SCRIPT" \ - && echo && $SCRIPT self-install - - exec echo "\nNow running" `$SCRIPT version` + if [ ! -w "$SCRIPT" ]; then + echo "You do not have permission to upgrade the installation in $SCRIPT" + exit 1 + else + echo "The script at $SCRIPT will be upgraded to the latest stable version." + echo -n "Do you want to continue [Y/n]? " + read RESP + case "$RESP" in + y|Y|"") + echo + echo "Upgrading..." + LEIN_SCRIPT_URL="http://github.com/technomancy/leiningen/raw/stable/bin/lein" + $HTTP_CLIENT "$SCRIPT" "$LEIN_SCRIPT_URL" \ + && chmod +x "$SCRIPT" \ + && echo && $SCRIPT self-install && echo && echo "Now running" `$SCRIPT version` + exit $?;; + *) + echo "Aborted." + exit 1;; + esac + fi else exec java -Xbootclasspath/a:"$CLOJURE_JAR" -client $JAVA_OPTS -cp "$CLASSPATH" -Dleiningen.version="$VERSION" clojure.main -e "(use 'leiningen.core)(-main $ESCAPED_ARGS)" fi diff --git a/src/leiningen/upgrade.clj b/src/leiningen/upgrade.clj index 033f6420..569f6014 100644 --- a/src/leiningen/upgrade.clj +++ b/src/leiningen/upgrade.clj @@ -1,3 +1,5 @@ (ns leiningen.upgrade "Upgrade Leiningen to the latest stable release.") -; actually a stub \ No newline at end of file + +; This file is only a placeholder. The real upgrade +; implementation can be found in the 'lein' script. \ No newline at end of file