Check that the "bootstrap" and "clean" subcommands are run in the project dir
[drupal-init-tools.git] / libexec / clean.sh
index 34ef55e..b1b4c16 100755 (executable)
@@ -20,7 +20,7 @@ set -e
 
 usage() {
   cat <<EOF
 
 usage() {
   cat <<EOF
-usage: drin $(basename $0 .sh) [-h|--help]
+usage: drin $(basename "$0" .sh) [-h|--help]
 
 Cleanup the project, removing all the installed files.
 
 
 Cleanup the project, removing all the installed files.
 
@@ -43,16 +43,18 @@ do
   shift
 done
 
   shift
 done
 
+[ -f "bootstrap.conf" ] || { echo "Aborting, run this command from the Drupal project directory." 1>&2; exit 1; }
+
 CONFIRMATION_STRING="YESIAMSURE"
 
 echo "WARNING! This removes any files in the config/ web/ and vendor/ directories."
 echo "Are you sure you want to continue?"
 echo
 CONFIRMATION_STRING="YESIAMSURE"
 
 echo "WARNING! This removes any files in the config/ web/ and vendor/ directories."
 echo "Are you sure you want to continue?"
 echo
-read -p "Type ${CONFIRMATION_STRING} to confirm: " INPUT
+read -r -p "Type ${CONFIRMATION_STRING} to confirm: " INPUT
 
 run() {
 
 run() {
-  echo $*
-  $*
+  echo "$@"
+  "$@"
 }
 
 [ "$INPUT" = "$CONFIRMATION_STRING" ] && run sudo rm -rf config/ web/ vendor/ composer.lock
 }
 
 [ "$INPUT" = "$CONFIRMATION_STRING" ] && run sudo rm -rf config/ web/ vendor/ composer.lock