home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / unixtex-6.1b-src.tgz / tar.out / contrib / unixtex / mkdirchain < prev    next >
Text File  |  1996-09-28  |  3KB  |  90 lines

  1. #!/bin/sh
  2. # Make directory hierarchy. 
  3. # Written by Noah Friedman <friedman@prep.ai.mit.edu>
  4. # (Minor modificatons by karl@cs.umb.edu.)
  5. # Public domain.
  6.  
  7. for file in ${1+"$@"} ; do 
  8.    oIFS="${IFS}"; IFS='/'; set - ${file}; IFS="${oIFS}"
  9.    test ".${1}" = "." && shift
  10.  
  11.    pathcomp=''
  12.  
  13.    while test $# -ne 0 ; do
  14.      pathcomp="${pathcomp}/${1}"
  15.      shift
  16.  
  17.      if test ! -d "${pathcomp}"; then
  18.         echo "mkdir $pathcomp" 1>&2
  19.         mkdir "${pathcomp}" || exit 1
  20.      fi
  21.    done
  22. done
  23.  
  24. exit 0
  25.  
  26. Date: Fri, 14 May 93 12:47:22 edt
  27. From: friedman@gnu.ai.mit.edu (Noah Friedman)
  28. To: meyering@idefix.comco.com
  29. Cc: gnu-prog-disc@gnu.ai.mit.edu
  30. Subject: Re: directory-making fragment
  31.  
  32. >Hi Noah.
  33. >I'm thinking about adding this to the *utils.
  34. >Have you heard anything that would indicate I shouldn't?
  35.  
  36. No, though I discovered from personal experience that this shell fragment
  37. is too long on some systems to appear on a command line.  The pty buffer on
  38. some systems is very small---if you try to do "make installdirs", you get
  39. an immediate failure.  Running it interactively just prints lots of C-g's. 
  40.  
  41. What I did for the texinfo distribution is to put the script in a separate
  42. file called `mkinstalldirs', then invoke it from the Makefile with the
  43. appropriate arguments.  Here is what it looks like:
  44.  
  45.     #!/bin/sh
  46.     # Make directory hierarchy. 
  47.     # Written by Noah Friedman <friedman@prep.ai.mit.edu>
  48.     # Public domain.
  49.  
  50.     umask 002
  51.     for file in ${1+"$@"} ; do 
  52.        oIFS="${IFS}"; IFS='/'; set - ${file}; IFS="${oIFS}"
  53.        test ".${1}" = "." && shift
  54.  
  55.        pathcomp=''
  56.  
  57.        while test $# -ne 0 ; do
  58.          pathcomp="${pathcomp}/${1}"
  59.          shift
  60.  
  61.          if test ! -d "${pathcomp}"; then
  62.             echo "mkdir $pathcomp" 1>&2
  63.             mkdir "${pathcomp}"
  64.          fi
  65.        done
  66.     done
  67.  
  68.     # eof
  69.  
  70.  
  71. >On May 7,  6:18am, Noah Friedman wrote:
  72. >| The following target might be a useful thing for people to include in all
  73. >| GNU Makefiles and make the `install' target depend on it.  This is what I
  74. >| did for Bison.
  75. >| 
  76. >| # Make sure all installation directories, e.g. $(bindir) actually exist by
  77. >| # making them if necessary.
  78. >| installdirs:
  79. >|     for file in $(bindir) $(datadir) $(libdir) $(infodir) $(mandir) ; do \
  80. >|        oIFS="$${IFS}"; IFS='/'; set - $${file}; IFS="$${oIFS}"; \
  81. >|        pathcomp=''; test ".$${1}" = "." && shift; \
  82. >|        while test $$# -ne 0 ; do \
  83. >|          pathcomp="$${pathcomp}/$${1}"; shift; \
  84. >|          if test ! -d "$${pathcomp}"; then \
  85. >|             echo "making directory $$pathcomp" 1>&2 ; \
  86. >|             mkdir "$${pathcomp}"; \
  87. >|          fi; \
  88. >|        done; \
  89. >|     done
  90.