Issue 6577: remove confirmation to delete output directory

Change-Id: Ib19986121a8988c6cae23527148a7b5d4a58663e

BUG=chromium-os:6577
TEST=(inside chroot) run 4 test cases from src/scripts/, using Ctrl+C to force abort (hence triggering "delete_prompt")
a.) (stdin tty) "./build_image --board=x86-generic < /dev/null", expected = no prompt and delete output dir; actual == expected
b.) (stdout tty) "./build_image --board=x86-generic > foo.txt", expected = no prompt and delete output dir; actual == expected
c.) (normal user case) "./build_image --board=x86-generic",
expected = prompt to delete output dir, if y, output dir is removed; actual == expected
d.) (normal user case) "./build_image --board=x86-generic", expected = prompt to delete output dir, if N, output dir is NOT removed; actual == expected

Review URL: http://codereview.chromium.org/3373003
This commit is contained in:
Tan Gao 2010-09-09 11:41:30 -07:00
parent 2e79fe48ce
commit 74a07cac15

View File

@ -319,14 +319,21 @@ cleanup() {
delete_prompt() {
echo "An error occurred in your build so your latest output directory" \
"is invalid."
read -p "Would you like to delete the output directory (y/N)? " SURE
SURE="${SURE:0:1}" # Get just the first character.
# Only prompt if both stdin and stdout are a tty. If either is not a tty,
# then the user may not be present, so we shouldn't bother prompting.
if tty -s && tty -s <&1; then
read -p "Would you like to delete the output directory (y/N)? " SURE
SURE="${SURE:0:1}" # Get just the first character.
else
SURE="y"
echo "Running in non-interactive mode so deleting output directory."
fi
if [ "${SURE}" == "y" ] ; then
sudo rm -rf "${OUTPUT_DIR}"
echo "Deleted ${OUTPUT_DIR}"
else
echo "Not deleting ${OUTPUT_DIR}. Note dev server updates will not work" \
"until you successfully build another image or delete this directory"
echo "Not deleting ${OUTPUT_DIR}."
fi
}