home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / linux / backup / star-1.3.1.tar.gz / star-1.3.1.tar / star-1.3.1 / conf / mkdir-sh < prev    next >
Text File  |  1998-12-14  |  1KB  |  59 lines

  1. #!/bin/sh
  2. #
  3. # Replacement for mkdir -p ... functionality.
  4. #
  5. # BSD-4.3, NeXT Step <= 3.x and similar don't accept the -p flag
  6. #
  7. # @(#)mkdir-sh    1.2 98/12/14 Copyright 1998 J. Schilling
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; either version 2, or (at your option)
  12. # any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. # GNU General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # along with this program; see the file COPYING.  If not, write to
  21. # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23. if [ $# -lt 1 ]; then
  24.     echo "Usage: mkdir-sh [-p] dir ...."
  25.     exit 1
  26. fi
  27.  
  28. dop=false
  29. case $1 in
  30. -p)
  31.     dop=true
  32.     shift
  33.     ;;
  34. esac
  35.  
  36. if [ $dop = false ]; then
  37.     for i in "$@"; do
  38.         mkdir "$i"
  39.     done
  40. else
  41.     for i in "$@"; do
  42.         if [ -d "$i" ]; then
  43.             continue
  44.         fi
  45.         # Don't use ${i:-.}, BSD4.3 doen't like it
  46.         #
  47.         fullname="$i"
  48.         if [ ."$i" = . ]; then
  49.             fullname=.
  50.         fi
  51.         dirname=`expr \
  52.             "$fullname/" : '\(/\)/*[^/]*//*$'  \| \
  53.             "$fullname/" : '\(.*[^/]\)//*[^/][^/]*//*$' \| \
  54.             .`
  55.         sh $0 -p "$dirname"
  56.         mkdir "$i"
  57.     done
  58. fi
  59.