logo

utils-std

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

shuf.sh (708B)


  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/shuf"
  6. plans=8
  7. . "$(dirname "$0")/tap.sh"
  8. t --input='' noargs '' ''
  9. t --input='foo' stdin '' 'foo'
  10. t --input='foo' stdin_dash '-' 'foo'
  11. # ioctl fail on BSDs
  12. # t devnull '/dev/null' ''
  13. t_seq_shuf_wc() {
  14. seq $seq | "$target" "$@" | wc -l | tr -d '[:space:]'
  15. }
  16. t_shuf_wc() {
  17. "$target" "$@" | wc -l | tr -d '[:space:]'
  18. }
  19. seq=20
  20. t_cmd seq20_n10 '10' t_seq_shuf_wc -n 10
  21. seq=7
  22. t_cmd seq7_n10 '7' t_seq_shuf_wc -n 10
  23. t_cmd e:foo '1' t_shuf_wc -e foo
  24. t_cmd e:foo_bar '2' t_shuf_wc -e foo bar
  25. t_cmd e:seq_7 '7' t_shuf_wc -e $(seq 7)