logo

utils-std

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

yes.sh (619B)


  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/yes"
  6. plans=5
  7. . "${WD}/tap.sh"
  8. yes_n3() { "$target" | head -n 3 ; }
  9. t_cmd n3 'y
  10. y
  11. y
  12. ' yes_n3
  13. yes_foo4() { "$target" foo | head -n 4 ; }
  14. t_cmd foo4 'foo
  15. foo
  16. foo
  17. foo
  18. ' yes_foo4
  19. yes_empty4() { "$target" "" | head -n 4 ; }
  20. t_cmd empty4 '
  21. ' yes_empty4
  22. yes_foo6() { "$target" foo | head -n 6 ; }
  23. t_cmd foo6 'foo
  24. foo
  25. foo
  26. foo
  27. foo
  28. foo
  29. ' yes_foo6
  30. yes_nl() { "$target" "$(printf 'foo\nbar')" | head -n 4 ; }
  31. t_cmd newline 'foo
  32. bar
  33. foo
  34. bar
  35. ' yes_nl