blob: e49445d6f328700b13522ab85226ef7430067019 [file] [log] [blame]
Rob Landley801c3d52012-01-30 07:40:32 -06001#!/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 "xargs spaces" "xargs" \
9 "one two three four\n" "" "one two\tthree \nfour\n\n"
10
11testing "xargs -n 0" "xargs -n 0 2>/dev/null || echo ok" "ok\n" \
12 "" "one \ntwo\n three"
13testing "xargs -n 2" "xargs -n 2" "one two\nthree\n" "" "one \ntwo\n three"
14testing "xargs -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 "xargs -s too long" "xargs -s 9 echo 2>/dev/null || echo ok" \
18 "one\ntwo\nok\n" "" "one two three"
19testing "xargs -s 13" "xargs -s 13 echo" "one two\nthree\n" "" "one \ntwo\n three"
20testing "xargs -s 12" "xargs -s 12 echo" "one\ntwo\nthree\n" "" "one \ntwo\n three"
21
22touch one two three
23testing "xargs command -opt" "xargs -n2 ls -1" "one\ntwo\nthree\n" "" \
24 "one two three"
25rm one two three
26
27exit
28
Rob Landley7aa651a2012-11-13 17:14:08 -060029testing "xargs -n exact match"
Rob Landley801c3d52012-01-30 07:40:32 -060030testing "xargs -s exact match"
31testing "xargs -s 0"
32testing "xargs -s impossible"
33
34# xargs command_not_found - returns 127
35# xargs false - returns 1