Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # required to be able to input the response
  4. exec < /dev/tty
  5.  
  6. # require to exit the docker container and kill the process
  7. trap printout SIGINT
  8. printout() {
  9. exit
  10. }
  11.  
  12. cmd_dry="$(pwd)/bin/php-cs-fixer fix --dry-run --diff";
  13. cmd_fix="$(pwd)/bin/php-cs-fixer fix --diff";
  14.  
  15. while true; do
  16.  
  17. read -p "Run Linter? (Y/n) " -n 1 -t 4 yn
  18.  
  19. if [[ ${yn} = "" ]]; then
  20. yn='Y';
  21. fi
  22.  
  23. case ${yn} in
  24. [Yy])
  25. ${cmd_dry};
  26. status=$?;
  27. if [[ ${status} -eq 0 ]]; then
  28. exit ${status};
  29. fi
  30. ${cmd_fix};
  31. exit ${status};
  32. ;;
  33. [Nn])
  34. exit 0;
  35. ;;
  36. *)
  37. echo "Please answer y or n for yes or no."
  38. ;;
  39. esac
  40. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement