File: do_clang_format.sh

package info (click to toggle)
rdfind 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 648 kB
  • sloc: cpp: 1,670; sh: 1,622; makefile: 32
file content (21 lines) | stat: -rwxr-xr-x 625 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh
#
#executes clang format
#
#
# copyright 2017 Paul Dreik
# Distributed under GPL v 2.0 or later, at your option.
# See LICENSE for further details.

#find clang format (usually named clang-format-3.x or clang-format, who knows)
CLANGFORMAT=$(find /usr/local/bin /usr/bin -executable -name "clang-format*" |grep -v -- -diff |sort -g |tail -n1)

if [ ! -x "$CLANGFORMAT" ] ; then
    echo failed finding clangformat
    exit 1
else
    echo found clang format: $CLANGFORMAT
fi

find . -maxdepth 1 -type f \( -name "*.h" -o -name "*.cpp" -o -name "*.cc" -o -name "*.hh" \) -print0 | \
    xargs -0 -n1 $CLANGFORMAT -i