Skip to content

Commit 2da7524

Browse files
committed
Harden CRLF handling for Docker shell scripts
Enforce LF line endings for docker and sbin shell scripts via .gitattributes so Linux container execution remains reliable. Also normalize ci.sh when sourced from mounted UnitTesting checkouts and normalize copied UnitTesting sbin scripts in the container as a runtime safety net for existing Windows working trees.
1 parent dd2f9c9 commit 2da7524

3 files changed

Lines changed: 24 additions & 7 deletions

File tree

.gitattributes

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
# files detected as binary untouched.
33
* text=auto
44

5+
# Shell scripts used in Linux containers must stay LF in the working tree.
6+
/docker/*.sh text eol=lf
7+
/docker/xvfb text eol=lf
8+
/sbin/*.sh text eol=lf
9+
510
# Files and directories with the attribute export-ignore won’t be added to
611
# archive files. See http://git-scm.com/docs/gitattributes for details.
712

813
# Git
9-
/.gitattributes export-ignore
1014
/.github/ export-ignore
1115
/.gitignore export-ignore
1216

docker/docker.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ set -e
55
BASEDIR=`dirname $0`
66

77
UNITTESTING_SOURCE=${UNITTESTING_SOURCE:-/unittesting}
8-
CISH="$UNITTESTING_SOURCE/sbin/ci.sh"
9-
if [ ! -f "$CISH" ]; then
10-
CISH="/tmp/ci.sh"
11-
if [ ! -f "$CISH" ]; then
12-
curl -s -L https://raw.githubusercontent.com/SublimeText/UnitTesting/master/sbin/ci.sh -o "$CISH"
13-
fi
8+
SOURCE_CISH="$UNITTESTING_SOURCE/sbin/ci.sh"
9+
CISH="/tmp/ci.sh"
10+
if [ -f "$SOURCE_CISH" ]; then
11+
# Normalize CRLF from mounted Windows checkouts.
12+
sed 's/\r$//' "$SOURCE_CISH" > "$CISH"
13+
elif [ ! -f "$CISH" ]; then
14+
curl -s -L https://raw.githubusercontent.com/SublimeText/UnitTesting/master/sbin/ci.sh -o "$CISH"
1415
fi
1516

1617
if [ -z "$PACKAGE" ]; then

docker/entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,22 @@ BOOTSTRAP_MARKER="$HOME/.cache/unittesting/bootstrap.done"
1010
sudo sh -e /etc/init.d/xvfb start
1111

1212
UNITTESTING_SOURCE=${UNITTESTING_SOURCE:-/unittesting}
13+
SUBLIME_TEXT_VERSION=${SUBLIME_TEXT_VERSION:-4}
14+
if [ "$SUBLIME_TEXT_VERSION" -ge 4 ]; then
15+
ST_PACKAGES_DIR="$HOME/.config/sublime-text/Packages"
16+
else
17+
ST_PACKAGES_DIR="$HOME/.config/sublime-text-$SUBLIME_TEXT_VERSION/Packages"
18+
fi
19+
1320
if [ -d "$UNITTESTING_SOURCE/sbin" ]; then
1421
# Ensure UnitTesting comes from the local checkout running this script,
1522
# so first runs do not depend on tagged upstream releases.
1623
(cd "$UNITTESTING_SOURCE" && PACKAGE=UnitTesting /docker.sh copy_tested_package overwrite)
24+
25+
# Normalize CRLF in shell scripts copied from Windows workspaces.
26+
if [ -d "$ST_PACKAGES_DIR/UnitTesting/sbin" ]; then
27+
find "$ST_PACKAGES_DIR/UnitTesting/sbin" -type f -name "*.sh" -exec sed -i 's/\r$//' {} +
28+
fi
1729
fi
1830

1931
if [ ! -f "$BOOTSTRAP_MARKER" ]; then

0 commit comments

Comments
 (0)