Skip to content

Instantly share code, notes, and snippets.

@KyleJamesWalker
Created March 16, 2018 21:33
Show Gist options
  • Save KyleJamesWalker/18042731a63f2410c1be9c793cef951a to your computer and use it in GitHub Desktop.
Save KyleJamesWalker/18042731a63f2410c1be9c793cef951a to your computer and use it in GitHub Desktop.
Makefile Prompts
something:
$(call prompt_run,echo "FUN!")
# Prompt the user to continue and exit the script if they choose no
define prompt_continue
@read -p "Contine and $(1)? " -n 1 -r REPLY; echo "\n"; \
if [[ $$REPLY =~ ^[Nn]$$ ]]; then exit 1; fi
endef
# Prompt the user to run a given command, and keep going if they choose no
define prompt_run
@read -p "Run $(1)? " -n 1 -r REPLY; echo "\n"; \
if [[ $$REPLY =~ ^[Yy]$$ ]]; then $(2); fi
endef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment