patch-mkinstalldirs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. --- Libnet-1.0.2a.orig/mkinstalldirs 1970-01-01 00:00:00.000000000 +0100
  2. +++ Libnet-1.0.2a/mkinstalldirs 2009-06-12 21:48:27.000000000 +0200
  3. @@ -0,0 +1,111 @@
  4. +#! /bin/sh
  5. +# mkinstalldirs --- make directory hierarchy
  6. +# Author: Noah Friedman <friedman@prep.ai.mit.edu>
  7. +# Created: 1993-05-16
  8. +# Public domain
  9. +
  10. +errstatus=0
  11. +dirmode=""
  12. +
  13. +usage="\
  14. +Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
  15. +
  16. +# process command line arguments
  17. +while test $# -gt 0 ; do
  18. + case $1 in
  19. + -h | --help | --h*) # -h for help
  20. + echo "$usage" 1>&2
  21. + exit 0
  22. + ;;
  23. + -m) # -m PERM arg
  24. + shift
  25. + test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
  26. + dirmode=$1
  27. + shift
  28. + ;;
  29. + --) # stop option processing
  30. + shift
  31. + break
  32. + ;;
  33. + -*) # unknown option
  34. + echo "$usage" 1>&2
  35. + exit 1
  36. + ;;
  37. + *) # first non-opt arg
  38. + break
  39. + ;;
  40. + esac
  41. +done
  42. +
  43. +for file
  44. +do
  45. + if test -d "$file"; then
  46. + shift
  47. + else
  48. + break
  49. + fi
  50. +done
  51. +
  52. +case $# in
  53. + 0) exit 0 ;;
  54. +esac
  55. +
  56. +case $dirmode in
  57. + '')
  58. + if mkdir -p -- . 2>/dev/null; then
  59. + echo "mkdir -p -- $*"
  60. + exec mkdir -p -- "$@"
  61. + fi
  62. + ;;
  63. + *)
  64. + if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
  65. + echo "mkdir -m $dirmode -p -- $*"
  66. + exec mkdir -m "$dirmode" -p -- "$@"
  67. + fi
  68. + ;;
  69. +esac
  70. +
  71. +for file
  72. +do
  73. + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
  74. + shift
  75. +
  76. + pathcomp=
  77. + for d
  78. + do
  79. + pathcomp="$pathcomp$d"
  80. + case $pathcomp in
  81. + -*) pathcomp=./$pathcomp ;;
  82. + esac
  83. +
  84. + if test ! -d "$pathcomp"; then
  85. + echo "mkdir $pathcomp"
  86. +
  87. + mkdir "$pathcomp" || lasterr=$?
  88. +
  89. + if test ! -d "$pathcomp"; then
  90. + errstatus=$lasterr
  91. + else
  92. + if test ! -z "$dirmode"; then
  93. + echo "chmod $dirmode $pathcomp"
  94. + lasterr=""
  95. + chmod "$dirmode" "$pathcomp" || lasterr=$?
  96. +
  97. + if test ! -z "$lasterr"; then
  98. + errstatus=$lasterr
  99. + fi
  100. + fi
  101. + fi
  102. + fi
  103. +
  104. + pathcomp="$pathcomp/"
  105. + done
  106. +done
  107. +
  108. +exit $errstatus
  109. +
  110. +# Local Variables:
  111. +# mode: shell-script
  112. +# sh-indentation: 2
  113. +# End:
  114. +# mkinstalldirs ends here