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