#! @SH@

# file: $ISIP_IFC/util/misc/isip_chmod/isip_chmod.sh
# version: $Id: isip_chmod.sh 9611 2004-07-03 18:06:03Z picone $
#
# the isip_chmod utility sets file protections to the isip standard
# (currently owner and group read/write; world read).
#

# important definitions
#
PROGRAM_NAME="isip_chmod";

ISIP_HELP_FILE="$ISIP_DEVEL/util/misc/isip_chmod/isip_chmod.help";
export ISIP_HELP_FILE;

DEFAULT_TOOL="chmod";
DEFAULT_MODE_OPTIONS="u+rw,g+rw,o+r,o-w";
DEFAULT_REC_OPTION="-R";
DEFAULT_EXE_0_OPTION=",a+x";
DEFAULT_EXE_1_OPTION=",a-x";

#define options
#
OPTION_REC_NAME="-R"
OPTION_EXE_0_NAME="+x"
OPTION_EXE_1_NAME="-x"

# execute a generic help function:
#  force the shellscript to exit if a help option is encountered.
set -e;
isip_function_help_0 $*;
set +e;

# check for a command line option:
#  if found, save the value and shift it off
#
OPTIONS="$DEFAULT_MODE_OPTIONS";

if (test "$1" = "$OPTION_REC_NAME") then
    OPTIONS="$DEFAULT_REC_OPTION ""$OPTIONS";
    shift;
fi

if (test "$1" = "$OPTION_EXE_0_NAME") then
    OPTIONS="$OPTIONS""$DEFAULT_EXE_0_OPTION";
    shift;
elif (test "$1" = "$OPTION_EXE_1_NAME") then
    OPTIONS="$OPTIONS""$DEFAULT_EXE_1_OPTION";
    shift;
fi

# change protections
#
$DEFAULT_TOOL $OPTIONS $*

#
# end of file
