#!/bin/sh
# $Id: makedir.SH,v 4.4 1991/09/09 20:23:31 sob Exp sob $
# 
# $Log: makedir.SH,v $
# Revision 4.4  1991/09/09  20:23:31  sob
# release 4.4
#
#
# 
# This software is Copyright 1991 by Stan Barber. 
#
# Permission is hereby granted to copy, reproduce, redistribute or otherwise
# use this software as long as: there is no monetary profit gained
# specifically from the use or reproduction or this software, it is not
# sold, rented, traded or otherwise marketed, and this copyright notice is
# included prominently in any copy made. 
#
# The author make no claims as to the fitness or correctness of this software
# for any use whatsoever, and it is provided as is. Any use of this software
# is at the user's own risk. 

export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)

case $# in
  0)
    /bin/echo "makedir pathname filenameflag"
    exit 1
    ;;
esac

: guarantee one slash before 1st component
case $1 in
  /*) ;;
  *)  set ./$1 $2 ;;
esac

: strip last component if it is to be a filename
case X$2 in
  X1) set `/bin/echo $1 | /bin/sed 's:\(.*\)/[^/]*$:\1:'` ;;
  *)  set $1 ;;
esac

: return reasonable status if nothing to be created
if /bin/test -d "$1" ; then
    exit 0
fi

list=''
while true ; do
    case $1 in
    */*)
	list="$1 $list"
	set `echo $1 | /bin/sed 's:\(.*\)/:\1 :'`
	;;
    *)
	break
	;;
    esac
done

set $list

for dir do
    /bin/mkdir $dir >/dev/null 2>&1
done
