logo

utils-std

Collection of commonly available Unix tools

realpath.t (3725B)


  1. #!/usr/bin/env cram
  2. # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. # SPDX-License-Identifier: MPL-2.0
  4. $ export path="$TESTDIR/../cmd"
  5. $ test "$($path/realpath .)" = "$(pwd)"
  6. $ $path/realpath /
  7. /
  8. $ $path/realpath /var
  9. /var
  10. $ $path/realpath /var/
  11. /var
  12. $ $path/realpath /var/empty
  13. /var/empty
  14. $ $path/realpath /var/empty/foo
  15. /var/empty/foo
  16. $ $path/realpath /var/empty/foo/
  17. /var/empty/foo
  18. $ $path/realpath /var/empty/foo//
  19. /var/empty/foo
  20. $ $path/realpath /var/empty/foo/bar
  21. realpath: Failed canonilizing parent of full path "/var/empty/foo/bar": No such file or directory
  22. [1]
  23. $ $path/realpath /var/empty/foo/bar/
  24. realpath: Failed canonilizing parent of full path "/var/empty/foo/bar": No such file or directory
  25. [1]
  26. $ $path/realpath /var/empty/foo/bar//
  27. realpath: Failed canonilizing parent of full path "/var/empty/foo/bar": No such file or directory
  28. [1]
  29. $ test "$($path/realpath .)" = "$(pwd)"
  30. $ $path/realpath /
  31. /
  32. $ $path/realpath /var
  33. /var
  34. $ $path/realpath /var/
  35. /var
  36. $ $path/realpath /var/empty
  37. /var/empty
  38. $ $path/realpath /var/empty/foo
  39. /var/empty/foo
  40. $ $path/realpath /var/empty/foo/
  41. /var/empty/foo
  42. $ $path/realpath /var/empty/foo//
  43. /var/empty/foo
  44. $ $path/realpath /var/empty/foo/bar
  45. realpath: Failed canonilizing parent of full path "/var/empty/foo/bar": No such file or directory
  46. [1]
  47. $ $path/realpath /var/empty/foo/bar/
  48. realpath: Failed canonilizing parent of full path "/var/empty/foo/bar": No such file or directory
  49. [1]
  50. $ $path/realpath /var/empty/foo/bar//
  51. realpath: Failed canonilizing parent of full path "/var/empty/foo/bar": No such file or directory
  52. [1]
  53. $ test "$($path/realpath -e .)" = "$(pwd)"
  54. $ $path/realpath -e /
  55. /
  56. $ $path/realpath -e /var
  57. /var
  58. $ $path/realpath -e /var/
  59. /var
  60. $ $path/realpath -e /var/empty
  61. /var/empty
  62. $ $path/realpath -e /var/empty/foo
  63. realpath: Failed canonilizing "/var/empty/foo": No such file or directory
  64. [1]
  65. $ $path/realpath -e /var/empty/foo/
  66. realpath: Failed canonilizing "/var/empty/foo/": No such file or directory
  67. [1]
  68. $ $path/realpath -e /var/empty/foo//
  69. realpath: Failed canonilizing "/var/empty/foo//": No such file or directory
  70. [1]
  71. $ $path/realpath -e /var/empty/foo/bar
  72. realpath: Failed canonilizing "/var/empty/foo/bar": No such file or directory
  73. [1]
  74. $ $path/realpath -e /var/empty/foo/bar/
  75. realpath: Failed canonilizing "/var/empty/foo/bar/": No such file or directory
  76. [1]
  77. $ $path/realpath -e /var/empty/foo/bar//
  78. realpath: Failed canonilizing "/var/empty/foo/bar//": No such file or directory
  79. [1]
  80. Non-directory
  81. $ $path/realpath /dev/null
  82. /dev/null
  83. $ $path/realpath -e /dev/null
  84. /dev/null
  85. $ $path/realpath -E /dev/null
  86. /dev/null
  87. $ $path/realpath /dev/null/
  88. realpath: Failed canonilizing "/dev/null/": Not a directory
  89. [1]
  90. $ $path/realpath -e /dev/null/
  91. realpath: Failed canonilizing "/dev/null/": Not a directory
  92. [1]
  93. $ $path/realpath -E /dev/null/
  94. realpath: Failed canonilizing "/dev/null/": Not a directory
  95. [1]
  96. $ $path/realpath /dev/null/..
  97. realpath: Failed canonilizing "/dev/null/..": Not a directory
  98. [1]
  99. $ $path/realpath -e /dev/null/..
  100. realpath: Failed canonilizing "/dev/null/..": Not a directory
  101. [1]
  102. $ $path/realpath -E /dev/null/..
  103. realpath: Failed canonilizing "/dev/null/..": Not a directory
  104. [1]
  105. Zero-separation
  106. $ $path/realpath -z /dev/null /var/empty
  107. /dev/null\x00/var/empty\x00 (no-eol) (esc)
  108. No final newline
  109. $ $path/realpath -n /dev/null /var/empty
  110. /dev/null
  111. /var/empty (no-eol)
  112. As required by "IEEE P1003.1™-202x/D4" -E and -e aren't errorneous
  113. $ $path/realpath -E -e /dev/null
  114. /dev/null