yearistype.sh 678 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #! /bin/sh
  2. : 'This file is in the public domain, so clarified as of'
  3. : '2006-07-17 by Arthur David Olson.'
  4. case $#-$1 in
  5. 2-|2-0*|2-*[!0-9]*)
  6. echo "$0: wild year: $1" >&2
  7. exit 1 ;;
  8. esac
  9. case $#-$2 in
  10. 2-even)
  11. case $1 in
  12. *[24680]) exit 0 ;;
  13. *) exit 1 ;;
  14. esac ;;
  15. 2-nonpres|2-nonuspres)
  16. case $1 in
  17. *[02468][048]|*[13579][26]) exit 1 ;;
  18. *) exit 0 ;;
  19. esac ;;
  20. 2-odd)
  21. case $1 in
  22. *[13579]) exit 0 ;;
  23. *) exit 1 ;;
  24. esac ;;
  25. 2-uspres)
  26. case $1 in
  27. *[02468][048]|*[13579][26]) exit 0 ;;
  28. *) exit 1 ;;
  29. esac ;;
  30. 2-*)
  31. echo "$0: wild type: $2" >&2 ;;
  32. esac
  33. echo "$0: usage is $0 year even|odd|uspres|nonpres|nonuspres" >&2
  34. exit 1