logo

utils-std

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

env.sh (1065B)


  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: execvp("/var/empty/e/no/ent", ...): No such file or directory
  15. '
  16. t posix_me_harder "-i FOO=BAR sh -c echo" '
  17. '
  18. t_args opt_S 'foo
  19. bar
  20. baz
  21. ' "-S printf '%s\n' foo bar baz"
  22. if ! gentoo_sandbox
  23. then
  24. t reset '-i FOO=BAR' 'FOO=BAR
  25. '
  26. t reset_chain "-i FOO=BAR $target" 'FOO=BAR
  27. '
  28. t uflag "-i FOOZ=BARZ $target -u FOOZ FOO=BAR" 'FOO=BAR
  29. '
  30. if grep -q HAS_GETOPT_LONG "${WD}/config.mk"; then
  31. t unsetflag "-i FOOZ=BARZ $target --unset=FOOZ FOO=BAR" 'FOO=BAR
  32. '
  33. else
  34. skip unsetflag 'Lacks getopt_long'
  35. fi
  36. # 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
  37. fi