From 330375f6926420014caf267cb25103431d75f74c Mon Sep 17 00:00:00 2001 From: Chris Masone Date: Mon, 29 Nov 2010 15:06:53 -0800 Subject: [PATCH] [crosutils] Add confirmation warning to cros_workon_make --scrub BUG=9717 TEST=run cros_workon_make --scrub and ensure that it only scrubs if the user types y or yes (case insensitive) Change-Id: Ic1f8020fcca8bd57924391fcbf075d3e2adc5e4a Review URL: http://codereview.chromium.org/5265009 --- bin/cros_workon_make | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/bin/cros_workon_make b/bin/cros_workon_make index 95cc709a5d..da2a3ebca5 100755 --- a/bin/cros_workon_make +++ b/bin/cros_workon_make @@ -58,12 +58,18 @@ if ! pkgfile=$("${EQUERYCMD}" which "${workon_name}" 2> /dev/null); then fi if [ "${FLAGS_scrub}" = "${FLAGS_TRUE}" ]; then - eval $(${EBUILDCMD} $(${EQUERYCMD} which ${workon_name}) info) - srcdir=$(readlink -m ${CROS_WORKON_SRCDIR}) - trunkdir=$(readlink -m ${CHROOT_TRUNK_DIR}) - project_path=${srcdir#${trunkdir}/} - if ! (cd "${GCLIENT_ROOT}/${project_path}" && git clean -xf); then - die "Could not scrub source directory" + warn "--scrub will destroy ALL FILES unknown to git!" + read -p "Are you sure you want to do this? [y|N]" resp + if egrep -qi "^y(es)?$" <(echo -n "${resp}"); then + eval $(${EBUILDCMD} $(${EQUERYCMD} which ${workon_name}) info) + srcdir=$(readlink -m ${CROS_WORKON_SRCDIR}) + trunkdir=$(readlink -m ${CHROOT_TRUNK_DIR}) + project_path=${srcdir#${trunkdir}/} + if ! (cd "${GCLIENT_ROOT}/${project_path}" && git clean -xf); then + die "Could not scrub source directory" + fi + else + info "Not scrubbing; exiting gracefully" fi exit 0 fi