xref: /freebsd/contrib/bc/tests/dc/scripts/easter.sh (revision 7ef62cebc2f965b0f640263e179276928885e33d)
1#!/bin/sh
2#
3# SPDX-License-Identifier: BSD-2-Clause
4#
5# Copyright (c) 2018-2023 Gavin D. Howard and contributors.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are met:
9#
10# * Redistributions of source code must retain the above copyright notice, this
11#   list of conditions and the following disclaimer.
12#
13# * Redistributions in binary form must reproduce the above copyright notice,
14#   this list of conditions and the following disclaimer in the documentation
15#   and/or other materials provided with the distribution.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27# POSSIBILITY OF SUCH DAMAGE.
28#
29
30set -e
31
32script="$0"
33
34testdir=$(dirname "${script}")
35
36# Just print the usage and exit with an error. This can receive a message to
37# print.
38# @param 1  A message to print.
39usage() {
40	if [ $# -eq 1 ]; then
41		printf '%s\n\n' "$1"
42	fi
43	printf 'usage: %s dc_exec year [options...]\n' "$script"
44	exit 1
45}
46
47. "$testdir/../../../scripts/functions.sh"
48
49if test $# -lt 2
50then
51	usage "Not enough arguments; need 2"
52fi
53
54dc_exec="$1"
55shift
56check_exec_arg "$dc_exec"
57
58year="$1"
59shift
60
61echo $year '
62[
63	ddsf
64	[
65		lfp
66		[too early
67		]P
68		q
69	]s@
70	1583>@
71	ddd19%1+sg100/1+d3*4/12-sx8*5+25/5-sz5*4/lx-10-sdlg11*20+lz+lx-30%
72	d
73	[30+]s@
74	0>@d
75	[
76		[1+]s@
77		lg11<@
78	]s@
79	25=@d
80	[1+]s@
81	24=@se44le-d
82	[30+]s@
83	21>@dld+7%-7+
84	[March ]sm
85	d
86	[
87		31-
88		[April ]sm
89	]s@
90	31<@psnlmPpsn1z>p
91]sp
92lpx' | "$dc_exec" "$@" | tr '\012' ' '
93echo ''
94