Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
1.9 KiB

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