logo

utils-std

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

tee.sh (1619B)


  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. plans=17
  6. target="${WD}/../cmd/tee"
  7. . "${WD}/tap.sh"
  8. t_file --infile="${WD}/inputs/all_bytes" all_bytes "${WD}/inputs/all_bytes"
  9. tmp_writefile="$(mktemp)"
  10. echo hello > "${tmp_writefile}"
  11. t_cmd writefile:grep '' grep -q hello "${tmp_writefile}"
  12. t_file --infile="${WD}/inputs/all_bytes" writefile "${WD}/inputs/all_bytes" "${tmp_writefile}"
  13. t_cmd writefile:cmp '' cmp "${tmp_writefile}" "${WD}/inputs/all_bytes"
  14. t_cmd writefile:rm '' rm "${tmp_writefile}"
  15. tmp_appendfile="$(mktemp)"
  16. echo hello > "${tmp_appendfile}"
  17. t_file --infile="${WD}/inputs/all_bytes" appendfile "${WD}/inputs/all_bytes" -a "${tmp_appendfile}"
  18. t_cmd writefile:cmp '' cmp "${tmp_appendfile}" "${WD}/outputs/tee/hello_all_bytes"
  19. t_cmd appendfile:rm '' rm "${tmp_appendfile}"
  20. tmp_noperm="$(mktemp)"
  21. t_cmd noperm:chmod_0000 '' chmod 0000 "${tmp_noperm}"
  22. t --exit=1 noperm "${tmp_noperm}" "tee: error: Failed opening file ‘${tmp_noperm}’: Permission denied
  23. " </dev/null
  24. t_cmd noperm:chmod_0600 '' chmod 0600 "${tmp_noperm}"
  25. t_cmd noperm:rm '' rm "${tmp_noperm}"
  26. t --input='' nullinput
  27. t --exit=1 --input='foo' writeslash './' 'tee: error: Failed opening file ‘./’: Is a directory
  28. '
  29. t --exit=1 --input='foo' enoent '/var/empty/e/no/ent' 'tee: error: Failed opening file ‘/var/empty/e/no/ent’: No such file or directory
  30. '
  31. t_file --infile="${WD}/inputs/all_bytes" doubledash "${WD}/inputs/all_bytes" --
  32. t --exit=1 --input='foo' tripledash '---' "tee: error: Unrecognised option: '--'
  33. "