summaryrefslogtreecommitdiff
path: root/coccinelle/run-coccinelle.sh
blob: 4c8c08227bbfa63fe803d07fc5bc40a05eb2de4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash -e

files="$(git ls-files ':/*.[ch]')"
args=

case "$1" in
        -i)
                args="$args --in-place"
                shift
                ;;
esac

for SCRIPT in ${@-coccinelle/*.cocci} ; do
        echo "--x-- Processing $SCRIPT --x--"
        TMPFILE=`mktemp`
        echo "+ spatch --sp-file $SCRIPT $args ..."
        spatch --sp-file $SCRIPT $args $files 2>"$TMPFILE" || cat "$TMPFILE"
        rm "$TMPFILE"
        echo -e "--x-- Processed $SCRIPT --x--\n"
done