logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git

ln.t (2670B)


  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:$PATH"
  5. $ test "$(command -v ln)" = "$TESTDIR/../cmd/ln"
  6. $ ln hard_enoent_src hard_enoent_dest
  7. ln: error: Failed creating hard link from 'hard_enoent_src' to 'hard_enoent_dest': No such file or directory
  8. [1]
  9. $ ln -s hard_enoent_ref1 hard_enoent_ref2 hard_enoent_dest
  10. ln: error: Failed creating symlink 'hard_enoent_dest/hard_enoent_ref1': No such file or directory
  11. [1]
  12. $ touch hard_file_src
  13. $ ln hard_file_src hard_file_dest
  14. $ test -f hard_file_dest
  15. $ rm hard_file_src hard_file_dest
  16. $ touch hard_file_src1 ./hard_file_src2
  17. $ mkdir hard_dir_dest
  18. $ ln hard_file_src1 ./hard_file_src2 hard_dir_dest
  19. $ test -f hard_dir_dest/hard_file_src1
  20. $ test -f hard_dir_dest/hard_file_src2
  21. $ rm hard_file_src1 hard_file_src2
  22. $ rm -r hard_dir_dest
  23. $ ln -s sym_enoent_ref sym_enoent_dest
  24. $ readlink sym_enoent_dest
  25. sym_enoent_ref
  26. $ rm sym_enoent_dest
  27. $ ln -s sym_enoent_ref1 sym_enoent_ref2 sym_enoent_dest
  28. ln: error: Failed creating symlink 'sym_enoent_dest/sym_enoent_ref1': No such file or directory
  29. [1]
  30. $ mkdir sym_dir_slash
  31. $ ln -s sym_enoent_ref1 ./sym_enoent_ref2 sym_dir_slash/
  32. $ readlink sym_dir_slash/sym_enoent_ref1
  33. sym_enoent_ref1
  34. $ readlink sym_dir_slash/sym_enoent_ref2
  35. ./sym_enoent_ref2
  36. $ rm -r sym_dir_slash
  37. $ mkdir sym_dir_noslash
  38. $ ln -s sym_enoent_ref1 ./sym_enoent_ref2 sym_dir_noslash
  39. $ readlink sym_dir_noslash/sym_enoent_ref1
  40. sym_enoent_ref1
  41. $ readlink sym_dir_noslash/sym_enoent_ref2
  42. ./sym_enoent_ref2
  43. $ rm -r sym_dir_noslash
  44. $ touch force_symlink
  45. $ ln -s foo force_symlink
  46. ln: error: Destination 'force_symlink' already exists
  47. [1]
  48. $ test -L force_symlink
  49. [1]
  50. $ ln -sf foo force_symlink
  51. $ test -L force_symlink
  52. $ rm force_symlink
  53. $ mkdir n_directory
  54. $ ln -s n_directory n_dir_symlink
  55. $ ln -sn //example.org n_dir_symlink
  56. ln: error: Destination 'n_dir_symlink' already exists
  57. [1]
  58. $ readlink n_dir_symlink
  59. n_directory
  60. $ ln -snf //example.org n_dir_symlink
  61. $ readlink n_dir_symlink
  62. //example.org
  63. $ rm -r n_directory n_dir_symlink
  64. $ mkdir e_target_dir
  65. $ ln -s e_ref_dir e_target_dir
  66. $ test ! -e e_ref_dir
  67. $ test ! -L e_target_dir
  68. $ test -d e_target_dir
  69. $ test -L e_target_dir/e_ref_dir
  70. $ echo mere copy > e_src_dir
  71. $ test -f e_src_dir
  72. $ ln e_src_dir e_target_dir
  73. $ echo hardlink > e_src_dir
  74. $ test -d e_target_dir
  75. $ test -f e_target_dir/e_src_dir
  76. $ cat e_target_dir/e_src_dir
  77. hardlink
  78. $ rm -r e_target_dir e_src_dir
  79. $ find .
  80. .