logo

utils-std

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

env.sh (1164B)


  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="${WD}/cmd/env"
  6. . "${WD}/test_functions.sh"
  7. plans=10
  8. gentoo_sandbox && plans=6
  9. . "${WD}/test-cmd/tap.sh"
  10. t exec_true 'true' ''
  11. t exec_echo 'echo' '
  12. '
  13. t --exit=1 exec_false 'false' ''
  14. t --exit=127 enoent '/var/empty/e/no/ent' "env: error: Failed executing '/var/empty/e/no/ent': No such file or directory
  15. "
  16. t posix_me_harder "-i FOO=BAR sh -c echo" '
  17. '
  18. if grep -q HAS_WORDEXP "${WD}/config.mk"; then
  19. t_args opt_S 'foo
  20. bar
  21. baz
  22. ' "-S printf '%s\n' foo bar baz"
  23. else
  24. skip opt_S 'Lacks <wordexp.h>'
  25. fi
  26. if ! gentoo_sandbox
  27. then
  28. t reset '-i FOO=BAR' 'FOO=BAR
  29. '
  30. t reset_chain "-i FOO=BAR $target" 'FOO=BAR
  31. '
  32. t uflag "-i FOOZ=BARZ $target -u FOOZ FOO=BAR" 'FOO=BAR
  33. '
  34. if grep -q HAS_GETOPT_LONG "${WD}/config.mk"; then
  35. t unsetflag "-i FOOZ=BARZ $target --unset=FOOZ FOO=BAR" 'FOO=BAR
  36. '
  37. else
  38. skip unsetflag 'Lacks getopt_long'
  39. fi
  40. # atf_check -s not-exit:0 -e "inline:env: Error: Unrecognised option: '-f'\nenv [-i] [-u key | --unset=key] [key=value ...] [command [args]]\n" ../cmd/env -f
  41. fi