xargs-L.sh revision 1.1
1#!/bin/sh 2# 3# $OpenBSD: xargs-L.sh,v 1.1 2010/03/25 01:43:47 schwarze Exp $ 4# 5# written by Ingo Schwarze <schwarze@openbsd.org> 2010 6# and placed in the public domain 7 8test_xargs() 9{ 10 printf 'Testing %13.13s with options "%s"\n' "\"$1\"" "$2" 11 expect=`printf "$3"` 12 result=`printf "$1" | xargs $2 ./showargs` 13 if [ "$result" != "$expect" ]; then 14 printf 'Expected "%s", but got "%s"\n' "$expect" "$result" 15 exit 1 16 fi 17} 18 19test_xargs 'a b' '' 'a|b|' 20test_xargs 'a b' '' 'a|b|' 21test_xargs 'a\nb' '' 'a|b|' 22test_xargs 'a\n\nb' '' 'a|b|' 23test_xargs 'a \nb' '' 'a|b|' 24test_xargs 'a\n b' '' 'a|b|' 25test_xargs 'a \n b' '' 'a|b|' 26test_xargs 'a\n \nb' '' 'a|b|' 27test_xargs 'a \n\nb' '' 'a|b|' 28 29test_xargs 'a\\ b' '' 'a b|' 30test_xargs 'a\\ \nb' '' 'a |b|' 31test_xargs 'a\n\\ b' '' 'a| b|' 32 33test_xargs 'a\\\nb' '' 'a\nb|' 34test_xargs 'a\n\\\nb' '' 'a|\nb|' 35test_xargs 'a \\\nb' '' 'a|\nb|' 36test_xargs 'a\\\n b' '' 'a\n|b|' 37test_xargs 'a \\\n b' '' 'a|\n|b|' 38 39test_xargs 'a b' '-L 1' 'a|b|' 40test_xargs 'a b' '-L 1' 'a|b|' 41test_xargs 'a\nb' '-L 1' 'a|\nb|' 42test_xargs 'a\n\nb' '-L 1' 'a|\nb|' 43test_xargs 'a \nb' '-L 1' 'a|b|' 44test_xargs 'a\n b' '-L 1' 'a|\nb|' 45test_xargs 'a \n b' '-L 1' 'a|b|' 46test_xargs 'a\n \nb' '-L 1' 'a|\nb|' 47test_xargs 'a \n\nb' '-L 1' 'a|b|' 48 49test_xargs 'a\\ b' '-L 1' 'a b|' 50test_xargs 'a\\ \nb' '-L 1' 'a |\nb|' 51test_xargs 'a\n\\ b' '-L 1' 'a|\n b|' 52 53test_xargs 'a\\\nb' '-L 1' 'a\nb|' 54test_xargs 'a\n\\\nb' '-L 1' 'a|\n\nb|' 55test_xargs 'a \\\nb' '-L 1' 'a|\nb|' 56test_xargs 'a\\\n b' '-L 1' 'a\n|b|' 57test_xargs 'a \\\n b' '-L 1' 'a|\n|b|' 58 59test_xargs 'a b' '-0' 'a b|' 60test_xargs 'a b' '-0' 'a b|' 61test_xargs 'a\nb' '-0' 'a\nb|' 62test_xargs 'a\n\nb' '-0' 'a\n\nb|' 63test_xargs 'a \nb' '-0' 'a \nb|' 64test_xargs 'a\n b' '-0' 'a\n b|' 65test_xargs 'a \n b' '-0' 'a \n b|' 66test_xargs 'a\n \nb' '-0' 'a\n \nb|' 67test_xargs 'a \n\nb' '-0' 'a \n\nb|' 68 69test_xargs 'a\\ b' '-0' 'a\\ b|' 70test_xargs 'a\\ \nb' '-0' 'a\\ \nb|' 71test_xargs 'a\n\\ b' '-0' 'a\n\\ b|' 72 73test_xargs 'a\\\nb' '-0' 'a\\\nb|' 74test_xargs 'a\n\\\nb' '-0' 'a\n\\\nb|' 75test_xargs 'a \\\nb' '-0' 'a \\\nb|' 76test_xargs 'a\\\n b' '-0' 'a\\\n b|' 77test_xargs 'a \\\n b' '-0' 'a \\\n b|' 78 79test_xargs 'a b\0c' '-0 -L 1' 'a b|c|' 80test_xargs 'a b\0c' '-0 -L 1' 'a b|c|' 81test_xargs 'a\nb\0c' '-0 -L 1' 'a\nb|\nc|' 82test_xargs 'a\n\nb\0c' '-0 -L 1' 'a\n\nb|\nc|' 83test_xargs 'a \nb\0c' '-0 -L 1' 'a \nb|c|' 84test_xargs 'a\n b\0c' '-0 -L 1' 'a\n b|\nc|' 85test_xargs 'a \n b\0c' '-0 -L 1' 'a \n b|c|' 86test_xargs 'a\n \nb\0c' '-0 -L 1' 'a\n \nb|\nc|' 87test_xargs 'a \n\nb\0c' '-0 -L 1' 'a \n\nb|c|' 88 89test_xargs 'a\\ b\0c' '-0 -L 1' 'a\\ b|c|' 90test_xargs 'a\\ \nb\0c' '-0 -L 1' 'a\\ \nb|c|' 91test_xargs 'a\n\\ b\0c' '-0 -L 1' 'a\n\\ b|\nc|' 92 93test_xargs 'a\\\nb\0c' '-0 -L 1' 'a\\\nb|\nc|' 94test_xargs 'a\n\\\nb\0c' '-0 -L 1' 'a\n\\\nb|\nc|' 95test_xargs 'a \\\nb\0c' '-0 -L 1' 'a \\\nb|\nc|' 96test_xargs 'a\\\n b\0c' '-0 -L 1' 'a\\\n b|\nc|' 97test_xargs 'a \\\n b\0c' '-0 -L 1' 'a \\\n b|\nc|' 98