#!/bin/sh

usage ()
{
    echo Usage: `basename $0` [-q] file... >&2
    exit 2
}

if [ $# -lt 1 ]
then
    usage
fi

if [ "$1" = "-q" ]
then
    quite=1
    shift
else
    quite=0
fi

recursive=1
if [ $# -lt 1 ]
then
	usage
fi

for i in "$@"
do
    if [ -d "$i" ]
    then
        chmod a+rwx "$i"
    else
        chmod a+rw-x "$i"
    fi
    if [ $recursive = 1 -a -d "$i" ]
    then
	if [ $quite = 0 ]
	then
		echo "Entering subdir $i ..."
		$0 "$i"/*
	else
		$0 -q "$i"/*
	fi
    fi
done
