mkinstalldirs 619 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/sh
  2. # Make directory hierarchy.
  3. # Written by Noah Friedman <friedman@prep.ai.mit.edu>
  4. # Public domain.
  5. defaultIFS='
  6. '
  7. IFS="${IFS-${defaultIFS}}"
  8. errstatus=0
  9. for file in ${1+"$@"} ; do
  10. oIFS="${IFS}"
  11. # Some sh's can't handle IFS=/ for some reason.
  12. IFS='%'
  13. set - `echo ${file} | sed -e 's@/@%@g' -e 's@^%@/@'`
  14. IFS="${oIFS}"
  15. pathcomp=''
  16. for d in ${1+"$@"} ; do
  17. pathcomp="${pathcomp}${d}"
  18. if test ! -d "${pathcomp}"; then
  19. echo "mkdir $pathcomp" 1>&2
  20. mkdir "${pathcomp}" || errstatus=$?
  21. fi
  22. pathcomp="${pathcomp}/"
  23. done
  24. done
  25. exit $errstatus
  26. # eof