logo

utils-std

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

readlink.sh (986B)


  1. #!/bin/sh
  2. # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. # SPDX-License-Identifier: MPL-2.0
  4. target="$(dirname "$0")/../cmd/readlink"
  5. plans=12
  6. . "$(dirname "$0")/tap.sh"
  7. t --exit=1 noargs '' 'readlink: error: Expected one file as argument, got 0
  8. Usage: readlink [-f|-e] [-n|-z] file...
  9. '
  10. t_cmd create_foobar '' ln -s //example.org/ foobar
  11. t read_foobar foobar '//example.org/
  12. '
  13. t read_foobar_no_nl '-n foobar' '//example.org/'
  14. t_cmd rm:foobar '' rm foobar
  15. t --exit=1 enoent /var/empty/e/no/ent "readlink: error: Failed reading symbolic link of '/var/empty/e/no/ent': No such file or directory
  16. "
  17. t_cmd touch:regular '' touch regular
  18. t --exit=1 readlink:regular regular "readlink: error: Failed reading symbolic link of 'regular': Invalid argument
  19. "
  20. t_cmd rm:regular '' rm regular
  21. t_cmd mkdir:dir '' mkdir dir
  22. t --exit=1 readlink:dir dir "readlink: error: Failed reading symbolic link of 'dir': Invalid argument
  23. "
  24. t_cmd rm:dir '' rm -r dir