File: yearistype

package info (click to toggle)
glibc 2.23-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 233,552 kB
  • sloc: ansic: 987,702; asm: 260,118; sh: 10,380; makefile: 9,474; python: 3,957; cpp: 3,956; perl: 2,207; awk: 1,907; pascal: 1,527; yacc: 291; sed: 80
file content (40 lines) | stat: -rwxr-xr-x 707 bytes parent folder | download | duplicates (58)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /bin/sh

: 'This file is in the public domain, so clarified as of'
: '2006-07-17 by Arthur David Olson.'

: '@(#)yearistype.sh	8.2'

case $#-$1 in
	2-|2-0*|2-*[!0-9]*)
		echo "$0: wild year - $1" >&2
		exit 1 ;;
esac

case $#-$2 in
	2-even)
		case $1 in
			*[24680])			exit 0 ;;
			*)				exit 1 ;;
		esac ;;
	2-nonpres|2-nonuspres)
		case $1 in
			*[02468][048]|*[13579][26])	exit 1 ;;
			*)				exit 0 ;;
		esac ;;
	2-odd)
		case $1 in
			*[13579])			exit 0 ;;
			*)				exit 1 ;;
		esac ;;
	2-uspres)
		case $1 in
			*[02468][048]|*[13579][26])	exit 0 ;;
			*)				exit 1 ;;
		esac ;;
	2-*)
		echo "$0: wild type - $2" >&2 ;;
esac

echo "$0: usage is $0 year even|odd|uspres|nonpres|nonuspres" >&2
exit 1