2010-02-03 23:54:06 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Test xargs compatibility
|
|
|
|
|
2010-04-18 14:18:31 +00:00
|
|
|
PAR=parallel
|
2010-02-03 23:54:06 +00:00
|
|
|
|
|
|
|
# Test -a and --arg-file: Read input from file instead of stdin
|
|
|
|
seq 1 10 >/tmp/$$
|
2010-04-18 14:18:31 +00:00
|
|
|
$PAR -a /tmp/$$ echo
|
|
|
|
$PAR --arg-file /tmp/$$ echo
|
2010-02-03 23:54:06 +00:00
|
|
|
|
|
|
|
# Test -i and --replace: Replace with argument
|
2010-04-18 14:18:31 +00:00
|
|
|
(echo a; echo END; echo b) | $PAR -k -i -eEND echo repl{}ce
|
|
|
|
(echo a; echo END; echo b) | $PAR -k --replace -eEND echo repl{}ce
|
|
|
|
(echo a; echo END; echo b) | $PAR -k -i+ -eEND echo repl+ce
|
|
|
|
(echo e; echo END; echo b) | $PAR -k -i'*' -eEND echo r'*'plac'*'
|
|
|
|
(echo a; echo END; echo b) | $PAR -k --replace + -eEND echo repl+ce
|
|
|
|
(echo a; echo END; echo b) | $PAR -k --replace== -eEND echo repl=ce
|
|
|
|
(echo a; echo END; echo b) | $PAR -k --replace = -eEND echo repl=ce
|
|
|
|
(echo a; echo END; echo b) | $PAR -k --replace=^ -eEND echo repl^ce
|
|
|
|
(echo a; echo END; echo b) | $PAR -k -I^ -eEND echo repl^ce
|
2010-02-03 23:54:06 +00:00
|
|
|
|
|
|
|
# Test -E: Artificial end-of-file
|
2010-04-18 14:18:31 +00:00
|
|
|
(echo include this; echo END; echo not this) | $PAR -k -E END echo
|
|
|
|
(echo include this; echo END; echo not this) | $PAR -k -EEND echo
|
2010-02-03 23:54:06 +00:00
|
|
|
|
|
|
|
# Test -e and --eof: Artificial end-of-file
|
2010-04-18 14:18:31 +00:00
|
|
|
(echo include this; echo END; echo not this) | $PAR -k -e END echo
|
|
|
|
(echo include this; echo END; echo not this) | $PAR -k -eEND echo
|
|
|
|
(echo include this; echo END; echo not this) | $PAR -k --eof=END echo
|
|
|
|
(echo include this; echo END; echo not this) | $PAR -k --eof END echo
|
2010-02-03 23:54:06 +00:00
|
|
|
|
|
|
|
# Test -n and --max-args: Max number of args per line (only with -X and -m)
|
2010-04-18 14:18:31 +00:00
|
|
|
(echo line 1;echo line 2;echo line 3) | $PAR -k -n1 -m echo
|
|
|
|
(echo line 1;echo line 1;echo line 2) | $PAR -k -n2 -m echo
|
|
|
|
(echo line 1;echo line 2;echo line 3) | $PAR -k -n1 -X echo
|
|
|
|
(echo line 1;echo line 1;echo line 2) | $PAR -k -n2 -X echo
|
|
|
|
(echo line 1;echo line 2;echo line 3) | $PAR -k --max-args=1 -X echo
|
|
|
|
(echo line 1;echo line 2;echo line 3) | $PAR -k --max-args 1 -X echo
|
|
|
|
(echo line 1;echo line 1;echo line 2) | $PAR -k --max-args=2 -X echo
|
|
|
|
(echo line 1;echo line 1;echo line 2) | $PAR -k --max-args 2 -X echo
|
2010-02-03 23:54:06 +00:00
|
|
|
|
|
|
|
# Test --max-procs and -P: Number of processes
|
2010-04-18 14:18:31 +00:00
|
|
|
seq 1 10 | $PAR -k --max-procs +0 echo max proc
|
|
|
|
seq 1 10 | $PAR -k -P 200% echo 200% proc
|
2010-02-03 23:54:06 +00:00
|
|
|
|
|
|
|
# Test --delimiter and -d: Delimiter instead of newline
|
|
|
|
# Yes there is supposed to be an extra newline for -d N
|
2010-04-18 14:18:31 +00:00
|
|
|
echo line 1Nline 2Nline 3 | $PAR -k -d N echo This is
|
|
|
|
echo line 1Nline 2Nline 3 | $PAR -k --delimiter N echo This is
|
|
|
|
printf "delimiter NUL line 1\0line 2\0line 3" | $PAR -k -d '\0' echo
|
|
|
|
printf "delimiter TAB line 1\tline 2\tline 3" | $PAR -k --delimiter '\t' echo
|
2010-02-03 23:54:06 +00:00
|
|
|
|
|
|
|
# Test --max-chars and -s: Max number of chars in a line
|
2010-04-18 14:18:31 +00:00
|
|
|
(echo line 1;echo line 1;echo line 2) | $PAR -k --max-chars 25 -X echo
|
|
|
|
(echo line 1;echo line 1;echo line 2) | $PAR -k -s 25 -X echo
|
2010-02-03 23:54:06 +00:00
|
|
|
|
|
|
|
# Test --no-run-if-empty and -r: This should give no output
|
2010-04-18 14:18:31 +00:00
|
|
|
echo " " | $PAR -r echo
|
|
|
|
echo " " | $PAR --no-run-if-empty echo
|
2010-02-03 23:54:06 +00:00
|
|
|
|
|
|
|
# Test --help and -h: Help output (just check we get the same amount of lines)
|
2010-04-18 14:18:31 +00:00
|
|
|
echo Output from -h and --help
|
|
|
|
$PAR -h | wc -l
|
|
|
|
$PAR --help | wc -l
|
2010-02-03 23:54:06 +00:00
|
|
|
|
|
|
|
# Test --version: Version output (just check we get the same amount of lines)
|
2010-04-18 14:18:31 +00:00
|
|
|
$PAR --version | wc -l
|
2010-02-03 23:54:06 +00:00
|
|
|
|
|
|
|
# Test --verbose and -t
|
2010-04-18 14:18:31 +00:00
|
|
|
(echo b; echo c; echo f) | $PAR -k -t echo {}ar 2>&1 >/dev/null
|
|
|
|
(echo b; echo c; echo f) | $PAR -k --verbose echo {}ar 2>&1 >/dev/null
|