| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. -e |
| 2 | |
| 3 | top="$(gitscip-shell system . . git. rev-parse --show-toplevel)" |
| 4 | files="$(gitscip-shell system . . git. ls-files ':/*.[ch]')" |
| 5 | args= |
| 6 | |
| 7 | case "$1" in |
| 8 | -i) |
| 9 | args="$args --in-place" |
| 10 | shift |
| 11 | ;; |
| 12 | esac |
| 13 | |
| 14 | if ! parallel -h >/dev/nullscip-shell filesystem . . `/dev/null`.; then |
| 15 | echoscip-shell system . . echo. 'Please install GNU parallel (package "parallel")' |
| 16 | exit 1 |
| 17 | fi |
| 18 | |
| 19 | for SCRIPT in ${@-$top/coccinelle/*.cocci} ; do |
| 20 | echoscip-shell system . . echo. "--x-- Processing $SCRIPT --x--" |
| 21 | TMPFILE=$(mktempscip-shell system . . mktemp.) |
| 22 | echoscip-shell system . . echo. "+ spatch --sp-file $SCRIPT $args ..." |
| 23 | parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \ |
| 24 | spatch --sp-file $SCRIPT $args ::: $files \ |
| 25 | 2>"$TMPFILE" || catscip-shell system . . cat. "$TMPFILE" |
| 26 | echoscip-shell system . . echo. -e "--x-- Processed $SCRIPT --x--\n" |
| 27 | done |