Skip to content

Commit 7a847fc

Browse files
committed
Use grep to implement verify-line-endings
1 parent f6e4703 commit 7a847fc

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/ci/scripts/verify-line-endings.sh

+11-11
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
# We check both in rust-lang/rust and in a submodule to make sure both are
55
# accurate. Submodules are checked out significantly later than the main
66
# repository in this script, so settings can (and do!) change between then.
7-
#
8-
# Linux (and maybe macOS) builders don't currently have dos2unix so just only
9-
# run this step on Windows.
107

118
set -euo pipefail
129
IFS=$'\n\t'
1310

1411
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
1512

16-
if isWindows; then
17-
# print out the git configuration so we can better investigate failures in
18-
# the following
19-
git config --list --show-origin
20-
dos2unix -ih Cargo.lock src/tools/rust-installer/install-template.sh
21-
endings=$(dos2unix -ic Cargo.lock src/tools/rust-installer/install-template.sh)
22-
# if endings has non-zero length, error out
23-
if [ -n "$endings" ]; then exit 1 ; fi
13+
# print out the git configuration so we can better investigate failures in
14+
# the following
15+
git config --list --show-origin
16+
# -U is necessary on Windows to stop grep automatically converting the line ending
17+
endings=$(grep -Ul $(printf '\r$') Cargo.lock src/tools/cargo/Cargo.lock) || true
18+
# if endings has non-zero length, error out
19+
if [[ -n $endings ]]; then
20+
echo "Error: found DOS line endings"
21+
# Print the files with DOS line endings
22+
echo "$endings"
23+
exit 1
2424
fi

0 commit comments

Comments
 (0)