Fix button save functio
[irreco.git] / irreco / strip-trailing-whitespace.sh
bloba2d6905fdd1771b88b22eae8fb6c803d0c9bd09e
1 #!/bin/bash
3 strip_whitespace()
5 COUNT=0
6 while read FILE; do
7 echo "Stripping whitespaces from: $FILE"
8 sed -i -r -e 's|[ \t]+$||' $FILE
9 ((COUNT++))
10 done
11 echo "Stripped whitespaces from $COUNT files."
14 if [ "$1" = '--all' ]; then
15 find ./src -type f -regex '.*\.[ch]' \
16 | xargs -d '\n' egrep -l '[[:space:]]+$' \
17 | strip_whitespace
18 elif [ -f "$1" ]; then
19 echo "$1" | strip_whitespace
20 else
21 echo "Usage: $0 FILENAME | --all"