Merge branch 'collectd-5.7' into collectd-5.8
[collectd.git] / contrib / format.sh
1 #!/bin/sh
2
3 # This script sends files to a web service using POST requests and reads back
4 # the correctly formatted source files. This allows to apply clang-format
5 # without having to install the tool locally.
6
7 if test $# -lt 1; then
8   echo "Usage $0 <file> [<file> ...]"
9   exit 1
10 fi
11
12 for i in "$@"; do
13   d="`dirname "${i}"`"
14   o="`TMPDIR="${d}" mktemp format.XXXXXX`"
15
16   curl --silent --data-binary "@-" https://format.collectd.org/ <"${i}" >"${o}"
17   if test $? -eq 0; then
18     cat "${o}" >"${i}"
19   fi
20   rm -f "${o}"
21 done