File: uncrustify-format-all.sh

package info (click to toggle)
rssguard 3.9.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 50,240 kB
  • sloc: cpp: 39,218; sql: 853; sh: 285; xml: 127; python: 59; makefile: 8
file content (66 lines) | stat: -rwxr-xr-x 1,733 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
#
# This file is part of RSS Guard.
#
# Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
# Copyright (C) 2010-2014 by David Rosca <nowrep@gmail.com>
#
# RSS Guard is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RSS Guard is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RSS Guard. If not, see <http:#www.gnu.org/licenses/>.

function usage {
  echo "Usage: $0 \"root-directory\"..."
  exit 1
}

if [ $# -eq 0 ]; then
  usage
fi

ASTYLE_CMD="uncrustify"

if [[ "$(uname -o)" == "Cygwin" ]]; then
  ASTYLE_RC="$(cygpath -w $(realpath $(dirname $0)))/uncrustify.cfg"
else
  ASTYLE_RC="$(realpath $(dirname $0))/uncrustify.cfg"
fi

echo "ASTYLE config file: $ASTYLE_RC"

# Check all args.
for dir in "$@"; do
  if [ ! -d "${dir}" ]; then
      echo "\"${dir}\" is not a directory..."
      usage
  fi
done

# Run the thing.
for dir in "$@"; do
  pushd "${dir}"
   
  for f in $(find . \
                -name '*.c' \
                -o -name '*.cc' \
                -o -name '*.cpp' \
                -o -name '*.h' \
                -o -name '*.hh' \
                -o -name '*.hpp'); do
    "${ASTYLE_CMD}" -c "$ASTYLE_RC" --replace "${f}"
  done
  
  # Remove backup files.
  find . -name "*-backup*~*" | xargs --no-run-if-empty rm -v
  
  popd
done