Created
July 20, 2019 07:22
-
-
Save BewareMyPower/038b5c2754d9d2fb6cc2fe7aa26d4b88 to your computer and use it in GitHub Desktop.
use clang-format format c/c++ files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| Usage() { | |
| echo "Usage: "$0" directory [maxdepth=1]" | |
| exit 1 | |
| } | |
| SHELL_DIR=$(dirname $0) | |
| if [[ $# -lt 1 || $1 = "-h" || $1 = "--help" ]]; then | |
| Usage | |
| fi | |
| if [ ! -d $1 ]; then | |
| echo "$1 is not directory" | |
| Usage | |
| fi | |
| MAXDEPTH=1 | |
| if [ $# -gt 1 ]; then | |
| MAXDEPTH=$2 | |
| fi | |
| REGEX=".*\.(h|c|cc|cpp)" | |
| FILES=$(find $1 -maxdepth $MAXDEPTH -regextype 'posix-egrep' -regex $REGEX) | |
| for i in $FILES; do | |
| echo "clang-format -i "$i | |
| clang-format -i $i | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment