indent.sh 388 B

123456789101112131415161718
  1. #!/bin/bash
  2. if [ $# -eq 0 ]; then
  3. echo "usage: $0 <file1 file2 ...>"
  4. exit 1
  5. fi
  6. if [ "$(type -t uncrustify)" = "" ]; then
  7. echo "Please install uncrustify first."
  8. exit 1
  9. fi
  10. TOOL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  11. uncrustify -c $TOOL_DIR/uncrustify.cfg -l C --replace $@
  12. # Remove trailing whitespace
  13. for file in $@; do
  14. sed -i -e's/[[:space:]]*$//' "$file"
  15. done