logo

utils-std

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

chown.t (2638B)


  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 chown)" = "$TESTDIR/../cmd/chown"
  6. $ test ! -f enoent
  7. $ chown nobody:nogroup enoent
  8. chown: error: Failed getting status for 'enoent': No such file or directory
  9. [1]
  10. $ touch id_unchanged
  11. $ chown -v $(ls -ld id_unchanged | awk '{print $3}') id_unchanged
  12. chown: Ownership already set to \d+:\d+ for 'id_unchanged' (re)
  13. $ rm id_unchanged
  14. $ touch uid_unchanged
  15. $ chown -v $(ls -lnd uid_unchanged | awk '{print $3}') uid_unchanged
  16. chown: Ownership already set to \d+:\d+ for 'uid_unchanged' (re)
  17. $ rm uid_unchanged
  18. $ touch name_unchanged
  19. $ chown -v $(ls -ld name_unchanged | awk '{print $3":"$4}') name_unchanged
  20. chown: Ownership already set to \d+:\d+ for 'name_unchanged' (re)
  21. $ rm name_unchanged
  22. $ touch uname_unchanged
  23. $ chown -v $(ls -ld uname_unchanged | awk '{print $3}') uname_unchanged
  24. chown: Ownership already set to \d+:\d+ for 'uname_unchanged' (re)
  25. $ rm uname_unchanged
  26. $ mkdir loop.d
  27. $ ln -s ../loop.d/ loop.d/loop
  28. $ chown -v $(ls -lnd loop.d | awk '{print $3}') loop.d
  29. chown: Ownership already set to \d+:\d+ for 'loop.d' (re)
  30. $ chown -v $(ls -lnd loop.d/loop | awk '{print $3}') loop.d/loop
  31. chown: Ownership already set to \d+:\d+ for 'loop.d/loop' (re)
  32. $ chown -v -h $(ls -lnd loop.d/loop | awk '{print $3}') loop.d/loop
  33. chown: Ownership already set to \d+:\d+ for 'loop.d/loop' (re)
  34. $ chown -v -R $(ls -lnd loop.d/ | awk '{print $3}') loop.d
  35. chown: Ownership already set to \d+:\d+ for 'loop.d' (re)
  36. chown: Ownership already set to \d+:\d+ for 'loop.d/loop' (re)
  37. $ chown -v -R $(ls -lnd loop.d/loop | awk '{print $3}') loop.d/loop
  38. chown: Ownership already set to \d+:\d+ for 'loop.d/loop' (re)
  39. $ chown -v -R -P $(ls -lnd loop.d/loop | awk '{print $3}') loop.d/loop
  40. chown: Ownership already set to \d+:\d+ for 'loop.d/loop' (re)
  41. $ chown -v -R -H $(ls -lnd loop.d/loop | awk '{print $3}') loop.d/loop
  42. chown: Ownership already set to \d+:\d+ for 'loop.d/loop' (re)
  43. chown: Ownership already set to \d+:\d+ for 'loop.d/loop/loop' (re)
  44. Non-portable, meanwhile adding a depth limit on chown itself could be rather limiting…
  45. $ chown -v -R -L $(ls -lnd loop.d/loop | awk '{print $3}') loop.d/loop >/dev/null 2>/dev/null
  46. [1]
  47. $ rm -r loop.d
  48. $ touch grp_unchanged
  49. $ chown -v $(ls -ld grp_unchanged | awk '{print ":"$4}') grp_unchanged
  50. chown: Ownership already set to \d+:\d+ for 'grp_unchanged' (re)
  51. $ rm grp_unchanged
  52. $ find .
  53. .