Use grep to implement verify-line-endings · rust-lang/rust@7a847fc

@@ -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.

107118

set -euo pipefail

129

IFS=$'\n\t'

13101411

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

151216-

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