5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
27 # Copyright (c) 1999 by Sun Microsystems, Inc.
28 # All rights reserved.
30 #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.8 */
31 # calendar.sh - calendar command, uses /usr/lib/calprog
34 USAGE
="usage: calendar [ - ]"
36 # mktmpdir - Create a private (mode 0700) temporary directory inside of /tmp
38 tmpdir
=/tmp
/calendar.$$
39 /usr
/bin
/mkdir
-m 700 $tmpdir ||
exit 1
46 /usr
/bin
/rm -rf $tmpdir
49 # Trap on SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGTERM
52 # Ignore trap if already set by the shell. NOTE: If /bin/sh
53 # is made XCU4 compliant, updates will also be required to this
54 # if statement because of XCU4 changes to the trap built-in.
55 TRAP_IGNORE
=`trap | egrep -c "^$i:\$"`
56 if [ "$TRAP_IGNORE" != "1" ]
58 # Cleanup; reset default value; send signal to process.
59 trap "cleanup; trap $i; kill -$i $$" $i
63 # POSIX.2 and XCU4 specify that if a utility accepts an operand,
64 # it also handle -- as a delimitor.
65 if [ "$1" = -- ]; then
70 0) if [ -f calendar
]; then
71 /usr
/lib
/calprog
> ${_tmp}
72 egrep -f ${_tmp} calendar
74 echo >&2 $0: `pwd`/calendar not found
78 -) if (rpcinfo
-p | fgrep
-s ypbind
); then
79 caldata
="ypcat passwd.byname | grep /`uname -n`/"
81 caldata
="cat /dev/null"
83 /usr
/lib
/calprog
> ${_tmp}
84 eval $caldata |
cat /etc
/passwd
- | \
85 sed 's/\([^:]*\):.*:\(.*\):[^:]*$/_dir=\2 _user=\1/' | \
87 eval ${_token} # evaluates _dir= and _user=
88 if [ -s ${_dir}/calendar
]; then
89 egrep -f ${_tmp} ${_dir}/calendar
2>/dev
/null \
91 if [ -s $tmpdir/calendar.$$
]; then
92 mail ${_user} < $tmpdir/calendar.$$
96 *) echo >&2 $0: illegal option
-- $@