opaque.sh revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
########################################################################
# #
# This software is part of the ast package #
# Copyright (c) 1989-2011 AT&T Intellectual Property #
# and is licensed under the #
# Eclipse Public License, Version 1.0 #
# by AT&T Intellectual Property #
# #
# A copy of the License is available at #
# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
# #
# Information and Software Systems Research #
# AT&T Research #
# Florham Park NJ #
# #
# Glenn Fowler <gsf@research.att.com> #
# David Korn <dgk@research.att.com> #
# Eduardo Krell <ekrell@adexus.cl> #
# #
########################################################################
:
# opaque file ...
# handles old (pre-92) and new style opaque
# @(#)opaque (AT&T Bell Laboratories) 10/11/95
function err_exit
{
exit 1
}
function usage
{
exit 2
}
command=${0##*/}
case $1 in
--) shift
break
;;
""|-\?) usage
;;
-*) print -u2 -- "$1: invalid option"
;;
esac
# the rest is in 2d
n=$(umask)
for i
do if [[ -f $i ]]
else case $i in
esac
if [[ ! -f .../... ]]
then if [[ ! -d ... ]]
then if mkdir ...
umask 777
> .../... || err_exit "$i: cannot opaque"
umask ${n#8#}
elif [[ ! -f ... ]]
then err_exit "...: cannot mkdir"
elif [[ -r ... || -w ... || -x ... || -s ... ]]
then err_exit "...: obsolescent opaque must be 0 mode file"
if mv ... ...3d
then if mv ...3d ...
then :
else rmdir ...
mv ...3d ...
err_exit "...: cannot rename obsolescent opaque"
fi
else rmdir ...3d
err_exit "...: cannot rename obsolescent opaque"
fi
fi
else umask 777
> .../... || err_exit "$i: cannot opaque"
umask ${n#8#}
fi
fi
fi
done