• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3[ -f testing.sh ] && . testing.sh
4
5#testing "name" "command" "result" "infile" "stdin"
6
7testing "xargs" "xargs && echo yes" "hello\nyes\n" "" "hello"
8testing "spaces" "xargs" \
9	"one two three four\n" "" "one two\tthree  \nfour\n\n"
10
11testing "-n 0" "xargs -n 0 2>/dev/null || echo ok" "ok\n" \
12	"" "one \ntwo\n three"
13testing "-n 2" "xargs -n 2" "one two\nthree\n" "" "one \ntwo\n three"
14testing "-n exact match" "xargs -n 3" "one two three\n" "" "one two three"
15testing "xargs2" "xargs -n2" "one two\nthree four\nfive\n" "" \
16	"one two three four five"
17testing "-s too long" "xargs -s 9 echo 2>/dev/null || echo ok" \
18	"one\ntwo\nok\n" "" "one two three"
19testing "-s 13" "xargs -s 13 echo" "one two\nthree\n" "" "one \ntwo\n three"
20testing "-s 12" "xargs -s 12 echo" "one\ntwo\nthree\n" "" "one \ntwo\n three"
21
22touch one two three
23testing "command -opt" "xargs -n2 ls -1" "one\ntwo\nthree\n" "" \
24	"one two three"
25rm one two three
26
27#testing "-n exact match"
28#testing "-s exact match"
29#testing "-s 0"
30#testing "-s impossible"
31
32# xargs command_not_found - returns 127
33# xargs false - returns 1
34