xargs.tests 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/sh
  2. # Copyright 2008 by Denys Vlasenko
  3. # Licensed under GPLv2, see file LICENSE in this source tree.
  4. . ./testing.sh
  5. # testing "test name" "command" "expected result" "file input" "stdin"
  6. testing "xargs -E _ stops on underscore" \
  7. "xargs -E _" \
  8. "a\n" \
  9. "" "a\n_\nb\n"
  10. testing "xargs -E ''" \
  11. "xargs -E ''" \
  12. "a _ b\n" \
  13. "" "a\n_\nb\n"
  14. testing "xargs -e without param" \
  15. "xargs -e" \
  16. "a _ b\n" \
  17. "" "a\n_\nb\n"
  18. testing "xargs does not stop on underscore ('new' GNU behavior)" \
  19. "xargs" \
  20. "a _ b\n" \
  21. "" "a\n_\nb\n"
  22. testing "xargs -s7 can take one-char input" \
  23. "xargs -s7 echo" \
  24. "a\n" \
  25. "" "a\n"
  26. testing "xargs -sNUM test 1" \
  27. "xargs -ts25 echo 2>&1 >/dev/null" \
  28. "echo 1 2 3 4 5 6 7 8 9 0\n""echo 1 2 3 4 5 6 7 8 9\n""echo 00\n" \
  29. "" "1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 00\n"
  30. testing "xargs -sNUM test 2" \
  31. "xargs -ts25 echo 1 2>&1 >/dev/null" \
  32. "echo 1 2 3 4 5 6 7 8 9 0\n""echo 1 2 3 4 5 6 7 8 9\n""echo 1 00\n" \
  33. "" "2 3 4 5 6 7 8 9 0 2 3 4 5 6 7 8 9 00\n"
  34. # see that we don't get "argument line too long",
  35. # but do see the last word, 99999, instead
  36. optional FEATURE_XARGS_SUPPORT_QUOTES
  37. testing "xargs argument line too long" \
  38. "seq 10000 99999 | sed -e 's/^/\"/' -e 's/$/\"/' | xargs echo | grep -o 99999; echo \$?" \
  39. "99999\n0\n" \
  40. "" ""
  41. testing "xargs -n1" \
  42. "xargs -n1 echo" \
  43. "1\n2\n3\n4\n5\n" \
  44. "" "1 2 3 4 5\n"
  45. testing "xargs -n2" \
  46. "xargs -n2 echo" \
  47. "1 2\n3 4\n5\n" \
  48. "" "1 2 3 4 5\n"
  49. SKIP=
  50. exit $FAILCOUNT