update-patches2 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env mksh
  2. #-
  3. # Copyright © 2014
  4. # Thorsten Glaser <tg@mirbsd.org>
  5. #
  6. # Provided that these terms and disclaimer and all copyright notices
  7. # are retained or reproduced in an accompanying document, permission
  8. # is granted to deal in this work without restriction, including un‐
  9. # limited rights to use, publicly perform, distribute, sell, modify,
  10. # merge, give away, or sublicence.
  11. #
  12. # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
  13. # the utmost extent permitted by applicable law, neither express nor
  14. # implied; without malicious intent or gross negligence. In no event
  15. # may a licensor, author or contributor be held liable for indirect,
  16. # direct, other damage, loss, or other issues arising in any way out
  17. # of dealing in the work, even if advised of the possibility of such
  18. # damage or existence of a defect, except proven that it results out
  19. # of said person’s immediate fault when using the work as intended.
  20. PATCH_LIST='patch-* *.patch'
  21. CURDIR=$PWD
  22. export CURDIR PATCH_LIST
  23. rm -f patches/*.new
  24. mksh "${TOPDIR}"/scripts/update-patches |&
  25. first=1
  26. set -A toedit
  27. while IFS= read -p -d '' -r; do
  28. if (( first )); then
  29. if [[ $REPLY = FAIL ]]; then
  30. rm -rf "${WRKDIR1}.orig"
  31. exit 1
  32. fi
  33. first=0
  34. fi
  35. toedit+=("$REPLY")
  36. done
  37. if (( !first )); then
  38. print -n 'edit patches: '
  39. read
  40. cd patches
  41. ${VISUAL:-${EDITOR:-vi}} "${toedit[@]}"
  42. cd ..
  43. fi
  44. rm -rf "${WRKDIR1}.orig"
  45. exit 0