Index: build_image |
diff --git a/build_image b/build_image |
index b4a6f1ac62add3154243086d7f6349c9acbafc23..6e2aa0e8a8c1a79f3c779fe63223a2765870af93 100755 |
--- a/build_image |
+++ b/build_image |
@@ -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 |
} |