-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpuppet-delint
More file actions
executable file
·47 lines (40 loc) · 1.01 KB
/
puppet-delint
File metadata and controls
executable file
·47 lines (40 loc) · 1.01 KB
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
#!/bin/bash
if [ "" = "${PUPPPET_DELINT_AWK}" ]; then
PUPPPET_DELINT_AWK=$(dirname $0)/puppet-delint.awk
fi
function trimws() {
# Remove all the dirty nasty dangling whitespace
sed -i -r "s/(\s+)$//" `find . -type f | grep -v git | xargs`
}
LINT=`mktemp`
find $1 -name '*.pp' | xargs puppet-lint --with-filename > $LINT
function bad_file() {
echo $1
}
function line_no() {
echo "$@" | awk '{print $NF }'
}
function classify_lint() {
echo "$@" | awk -f ${PUPPPET_DELINT_AWK}
}
while read lint
do
BADFILE=`bad_file ${lint}`
BADLINE=`line_no ${lint}`
LINTTYPE=`classify_lint ${lint}`
echo "$BADFILE:$BADLINE - $LINTTYPE"
case $LINTTYPE in
filemode)
echo "Original:"
sed -n "${BADLINE}p" $BADFILE
echo "Replacement:"
sed -r -i "${BADLINE}s/([0-9]{3,4})/\'\1'/" $BADFILE
;;
quotes)
echo "Original:"
sed -n "${BADLINE}" $BADFILE
echo "Replacement:"
sed -r -i "${BADLINE}s/\"(.*?)\"/'\1'/" $BADFILE
;;
esac
done < $LINT