Skip to content

Instantly share code, notes, and snippets.

@seanhamlin
Created December 12, 2023 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanhamlin/11927cf1f57e4f6b7bd810bd560ab7f7 to your computer and use it in GitHub Desktop.
Save seanhamlin/11927cf1f57e4f6b7bd810bd560ab7f7 to your computer and use it in GitHub Desktop.
# Use basic filtering of `drush status` to hopefully ensure more broader support
# for various drush versions.
DRUPAL_VERSION=$(drush status | grep -i "drupal version" | awk '{print $NF}');
if [ "${DRUPAL_VERSION%.*}" == "7" ] ; then
if drush cc all; then echo "drush cc all complete"; else exit $?; fi;
elif [ "${DRUPAL_VERSION%.*.*}" -ge "8" ] ; then
if drush cr -y; then echo "drush cache:rebuild complete"; else exit $?; fi;
else \
echo "could not clear cache for found Drupal version ${DRUPAL_VERSION}";
exit 1;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment