#! /bin/sh
#
# Copyright 1991 Digital Equipment Corporation.
# Distributed only by permission.
#
# Last modified on Fri Mar 20 20:07:54 PST 1992 by muller                      .
#      modified on Tue Aug 20 19:15:31 PST 1991 by kalsow                      .
#      modified on Thu May  9 10:25:01 PDT 1991 by chiu                        .

# Takes 1 arg:  
#    $1 = filename
# This shell script creates all directories, if missing, in filename

FILENAME=$1

if /bin/test $# -eq 0 -o $# -gt 1
  then
    /bin/echo Usage: $0 "<filename>" 1>&2
    exit 1
  fi

# strip last arc off filename
SAVEIFS="$IFS" 
IFS="/"
set $FILENAME
IFS="$SAVEIFS"
LASTDIR=""
while /bin/test $# -gt 1 ; do
  LASTDIR="${LASTDIR}/${1}"
  shift
done

CURDIR=`/bin/pwd` 

SAVEIFS="$IFS" 
IFS="/"
set $LASTDIR
IFS="$SAVEIFS"
CUMPATH=""
while /bin/test $# -ne 0 ; do
  CUMPATH="${CUMPATH}/${1}"
  if /bin/test ! -d $1
    then
      if /bin/test ! -w .
        then
          /bin/echo "Not allowed to create $CUMPATH" 1>&2
          exit 1
        else
          /bin/mkdir $1
      fi
  fi
  cd $1
  shift
done

cd $CURDIR



