mkinst3.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #! /bin/sh
  2. # Copyright (C) 2005-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Test mkinstalldirs with spaces in directory names.
  17. am_create_testdir=empty
  18. . test-init.sh
  19. cwd=$(pwd) || fatal_ "getting current working directory"
  20. # Make sure the directory we will create can be created...
  21. mkdir '~a b' && mkdir '~a b/-x y' \
  22. || skip_ "directory names with spaces and metacharacters not accepted"
  23. rm -rf '~a b'
  24. get_shell_script mkinstalldirs
  25. # Test mkinstalldirs with the installed mkdir.
  26. ./mkinstalldirs '~a b/-x y'
  27. test -d '~a b/-x y'
  28. rm -rf '~a b'
  29. # Trick mkinstalldirs into thinking mkdir does not support -p.
  30. mkdir bin
  31. cat >bin/mkdir <<'EOF'
  32. #!/bin/sh
  33. for arg
  34. do
  35. case $arg in
  36. -p) exit 1;;
  37. esac
  38. done
  39. PATH=$AM_PATH
  40. export PATH
  41. exec mkdir "$@"
  42. EOF
  43. chmod +x bin/mkdir
  44. AM_PATH=$PATH; export AM_PATH
  45. PATH=$cwd/bin$PATH_SEPARATOR$PATH; export PATH
  46. # Test mkinstalldirs without mkdir -p.
  47. ./mkinstalldirs '~a b/-x y'
  48. test -d '~a b/-x y'
  49. rm -rf '~a b'
  50. ./mkinstalldirs "$cwd///~a b//-x y"
  51. test -d "$cwd/~a b/-x y"
  52. rm -rf '~a b'
  53. :