#!/bin/sh version="1.0 Time-stamp: " # pmkdir [ -m MODE | -g GROUP | -o OWNER | -n ] DIR # -- create a directory DIR, including any necessary # intervening directories. # Also takes note of 3 enbvironment variables: # GROUP -- group to give to new directories # OWNER -- owner for new directories # MODE -- mode for new directories # If called with the name of an existing directory, this will still # change group, mode, owner (if they are set). me=`basename $0` while test $# -gt 0; do case $1 in --m*=*) MODE=`expr $1 : '.*=\(.*\)$'` ; export MODE ;; -m|--m*) MODE=$2 ; export MODE; shift ;; --g*=*) GROUP=`expr $1 : '.*=\(.*\)$'` ; export GROUP ;; -g|--g*) GROUP=$2; export GROUP; shift ;; --o*=*) OWNER=`expr $1 : '.*=\(.*\)$'` ; export OWNER ;; -o|--o*) OWNER=$2; export OWNER; shift ;; -n*|--n*) echo=echo ;; -h|--h*) cat <<'@EOF' $me -- make directory and any parent directories necessary $me [--no-create] [--mode=MODE] [--group=GROUP] [--owner=OWNER] DIR... $me --help | --version MODE is a mode for the new directory(s); see chmod(1). GROUP and OWNER are the group and owner; see chown(1) and chgrp(1). The --no-create option means don't do anything, print the commands instead. If not specified on the command line, the environment variables MODE, GROUP and OWNER are used. If there are no environment variables, the defaults used by mkdir(1) apply. @EOF exit 0 ;; -V|--v*) echo $me for PDCMAC $version exit 0 ;; -*) echo >&2 `basename $0`: $1: not understood exit 2 ;; *) p=`dirname $1` test -d $p || $0 $p || exit 1 $echo mkdir $1 || exit 1 test -n "$OWNER" && { $echo chgrp $OWNER $1 || exit 1; } test -n "$GROUP" && { $echo chgrp $GROUP $1 || exit 1; } test -n "$MODE" && { $echo chmod $MODE $1 || exit 1; } ;; esac shift done