logo

utils-std

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

pwd.sh (618B)


  1. #!/bin/sh
  2. # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. # SPDX-License-Identifier: MPL-2.0
  4. WD="$(dirname "$0")"
  5. target="$(realpath "$WD/../cmd/pwd")"
  6. plans=3
  7. . "$(dirname "$0")/tap.sh"
  8. t noargs '' "${PWD?}
  9. "
  10. t --exit=1 usage '-H' 'usage: pwd
  11. '
  12. if command -v mktemp >/dev/null 2>/dev/null
  13. then
  14. tmpdir="$(mktemp -d)" || exit 1
  15. test -d "$tmpdir" || exit 1
  16. oldpwd="$PWD"
  17. cd "$tmpdir" || exit 1
  18. (
  19. cd "$oldpwd" || exit 1
  20. rm -r "$tmpdir" || exit 1
  21. )
  22. t --exit=1 enoent '' 'pwd: getcwd: No such file or directory
  23. '
  24. cd "$oldpwd"
  25. else
  26. skip enoent 'requires mktemp(1)'
  27. fi