]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/scripts/eofnl
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / spdk / scripts / eofnl
1 #!/usr/bin/env bash
2 # Make sure file has a trailing newline
3
4 f="$1"
5
6 if [ -z "$f" ]; then
7 echo "usage: $0 <file>"
8 exit 1
9 fi
10
11 if [ ! -f "$f" ]; then
12 exit 0
13 fi
14
15 if [[ $(tail -c1 "$f") ]]; then
16 echo "$f: No newline at end of file"
17 echo '' >> "$f"
18 exit 1
19 fi
20
21 if [[ ! $(tail -c2 "$f") ]]; then
22 echo "$f: Extra trailing newline"
23 exit 1
24 fi
25
26 if grep -q $'\r' "$f"; then
27 echo "$f: DOS-style newlines"
28 dos2unix "$f" &> /dev/null
29 exit 1
30 fi
31
32 if grep -q $'[\t ]$' "$f"; then
33 echo "$f: Trailing whitespace"
34 sed -i $'s/[ \t]*$//' "$f"
35 exit 1
36 fi
37
38 exit 0