File: format.sh

package info (click to toggle)
collectd 5.12.0-27
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,160 kB
  • sloc: ansic: 120,848; perl: 20,684; php: 3,007; makefile: 2,441; java: 1,713; javascript: 920; python: 892; sh: 799; cpp: 638; yacc: 231; sql: 198; lex: 146; ruby: 49; xml: 44
file content (21 lines) | stat: -rwxr-xr-x 522 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh

# This script sends files to a web service using POST requests and reads back
# the correctly formatted source files. This allows to apply clang-format
# without having to install the tool locally.

if test $# -lt 1; then
  echo "Usage $0 <file> [<file> ...]"
  exit 1
fi

for i in "$@"; do
  d="`dirname "${i}"`"
  o="`TMPDIR="${d}" mktemp format.XXXXXX`"

  curl --silent --data-binary "@-" https://format.collectd.org/ <"${i}" >"${o}"
  if test $? -eq 0; then
    cat "${o}" >"${i}"
  fi
  rm -f "${o}"
done