-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcal
More file actions
executable file
·66 lines (61 loc) · 1.68 KB
/
cal
File metadata and controls
executable file
·66 lines (61 loc) · 1.68 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright 2014 Jeremy Brubaker <jbru362@gmail.com>
#
# abstract: cal(1) wrapper with a nicer interface
#
# Usage: cal [month [year]] [cal(1) options]
#
# Separate options and arguments
#
for i; do
case $i in
-h)
printf "%s\n" "Usage: cal [month [year]] [options]"
exit
;;
-*) opts="$opts $i" ;;
*) args="$args $i" ;;
esac
done
# Process args if we have any
if test "$args"; then
set "$args"
case $# in
1) m=$1; set "$(date)"; y=$6 ;; # 1 arg; use this year
*) m=$1; y=$2 ;;
esac
fi
# Convert month arg to a number
#
case $m in
[jJ]an*) m=1 ;;
[fF]eb*) m=2 ;;
[mM]ar*) m=3 ;;
[aA]pr*) m=4 ;;
[mM]ay*) m=5 ;;
[jJ]un*) m=6 ;;
[jJ]ul*) m=7 ;;
[aA]ug*) m=8 ;;
[sS]ep*) m=9 ;;
[oO]ct*) m=10 ;;
[nN]ov*) m=11 ;;
[dD]ec*) m=12 ;;
*) y=$m; m="" ;; # plain year
esac
# Do not quote in order to allow for empty arguments
# shellcheck disable=SC2086
/usr/bin/cal $opts $m $y