]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - coccinelle/run-coccinelle.sh
coccinelle: add option to make changes in place
[thirdparty/systemd.git] / coccinelle / run-coccinelle.sh
index 8c4ed07dd8b97a7b22ec9cd4ad4a633777abaca4..4c8c08227bbfa63fe803d07fc5bc40a05eb2de4a 100755 (executable)
@@ -1,12 +1,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 ..."
-        spatch --sp-file $SCRIPT $files 2>"$TMPFILE" || cat "$TMPFILE"
+        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