Skip to content

Commit 3985b6a

Browse files
authored
Merge pull request #68 from mderriey/force-lf-line-endings-for-bash-files
Force LF line endings for Bash scripts
2 parents baad43a + 4b0d824 commit 3985b6a

5 files changed

Lines changed: 29 additions & 22 deletions

File tree

.devcontainer/library-scripts/azcli-debian.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if ! dpkg -s apt-transport-https curl ca-certificates lsb-release > /dev/null 2>
2323
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
2424
apt-get update
2525
fi
26-
apt-get -y install --no-install-recommends apt-transport-https curl ca-certificates lsb-release gnupg2
26+
apt-get -y install --no-install-recommends apt-transport-https curl ca-certificates lsb-release gnupg2
2727
fi
2828

2929
# Install the Azure CLI

.devcontainer/library-scripts/common-debian.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then
113113
manpages \
114114
manpages-dev \
115115
init-system-helpers"
116-
116+
117117
# Needed for adding manpages-posix and manpages-posix-dev which are non-free packages in Debian
118118
if [ "${ADD_NON_FREE_PACKAGES}" = "true" ]; then
119119
# Bring in variables from /etc/os-release like VERSION_CODENAME
@@ -124,7 +124,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then
124124
sed -i -E "s/deb-src http:\/\/(deb|httpredir)\.debian\.org\/debian ${VERSION_CODENAME}-updates main/deb http:\/\/\1\.debian\.org\/debian ${VERSION_CODENAME}-updates main contrib non-free/" /etc/apt/sources.list
125125
sed -i "s/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main contrib non-free/" /etc/apt/sources.list
126126
sed -i "s/deb-src http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main contrib non-free/" /etc/apt/sources.list
127-
sed -i "s/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main contrib non-free/" /etc/apt/sources.list
127+
sed -i "s/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main contrib non-free/" /etc/apt/sources.list
128128
sed -i "s/deb-src http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main contrib non-free/" /etc/apt/sources.list
129129
# Handle bullseye location for security https://www.debian.org/releases/bullseye/amd64/release-notes/ch-information.en.html
130130
sed -i "s/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main contrib non-free/" /etc/apt/sources.list
@@ -140,7 +140,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then
140140
if [[ ! -z $(apt-cache --names-only search ^libssl1.1$) ]]; then
141141
package_list="${package_list} libssl1.1"
142142
fi
143-
143+
144144
# Install appropriate version of libssl1.0.x if available
145145
libssl_package=$(dpkg-query -f '${db:Status-Abbrev}\t${binary:Package}\n' -W 'libssl1\.0\.?' 2>&1 || echo '')
146146
if [ "$(echo "$LIlibssl_packageBSSL" | grep -o 'libssl1\.0\.[0-9]:' | uniq | sort | wc -l)" -eq 0 ]; then
@@ -155,7 +155,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then
155155

156156
echo "Packages to verify are installed: ${package_list}"
157157
apt-get -y install --no-install-recommends ${package_list} 2> >( grep -v 'debconf: delaying package configuration, since apt-utils is not installed' >&2 )
158-
158+
159159
# Install git if not already installed (may be more recent than distro version)
160160
if ! type git > /dev/null 2>&1; then
161161
apt-get -y install --no-install-recommends git
@@ -174,7 +174,7 @@ fi
174174
# Ensure at least the en_US.UTF-8 UTF-8 locale is available.
175175
# Common need for both applications and things like the agnoster ZSH theme.
176176
if [ "${LOCALE_ALREADY_SET}" != "true" ] && ! grep -o -E '^\s*en_US.UTF-8\s+UTF-8' /etc/locale.gen > /dev/null; then
177-
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
177+
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
178178
locale-gen
179179
LOCALE_ALREADY_SET="true"
180180
fi
@@ -183,12 +183,12 @@ fi
183183
group_name="${USERNAME}"
184184
if id -u ${USERNAME} > /dev/null 2>&1; then
185185
# User exists, update if needed
186-
if [ "${USER_GID}" != "automatic" ] && [ "$USER_GID" != "$(id -g $USERNAME)" ]; then
186+
if [ "${USER_GID}" != "automatic" ] && [ "$USER_GID" != "$(id -g $USERNAME)" ]; then
187187
group_name="$(id -gn $USERNAME)"
188188
groupmod --gid $USER_GID ${group_name}
189189
usermod --gid $USER_GID $USERNAME
190190
fi
191-
if [ "${USER_UID}" != "automatic" ] && [ "$USER_UID" != "$(id -u $USERNAME)" ]; then
191+
if [ "${USER_UID}" != "automatic" ] && [ "$USER_UID" != "$(id -u $USERNAME)" ]; then
192192
usermod --uid $USER_UID $USERNAME
193193
fi
194194
else
@@ -198,7 +198,7 @@ else
198198
else
199199
groupadd --gid $USER_GID $USERNAME
200200
fi
201-
if [ "${USER_UID}" = "automatic" ]; then
201+
if [ "${USER_UID}" = "automatic" ]; then
202202
useradd -s /bin/bash --gid $USERNAME -m $USERNAME
203203
else
204204
useradd -s /bin/bash --uid $USER_UID --gid $USERNAME -m $USERNAME
@@ -213,7 +213,7 @@ if [ "${USERNAME}" != "root" ] && [ "${EXISTING_NON_ROOT_USER}" != "${USERNAME}"
213213
fi
214214

215215
# ** Shell customization section **
216-
if [ "${USERNAME}" = "root" ]; then
216+
if [ "${USERNAME}" = "root" ]; then
217217
user_rc_path="/root"
218218
else
219219
user_rc_path="/home/${USERNAME}"
@@ -250,9 +250,9 @@ fi
250250
# Set the default git editor if not already set
251251
if [ -z "$(git config --get core.editor)" ] && [ -z "${GIT_EDITOR}" ]; then
252252
if [ "${TERM_PROGRAM}" = "vscode" ]; then
253-
if [[ -n $(command -v code-insiders) && -z $(command -v code) ]]; then
253+
if [[ -n $(command -v code-insiders) && -z $(command -v code) ]]; then
254254
export GIT_EDITOR="code-insiders --wait"
255-
else
255+
else
256256
export GIT_EDITOR="code --wait"
257257
fi
258258
fi
@@ -329,7 +329,7 @@ codespaces_zsh="$(cat \
329329
# Codespaces zsh prompt theme
330330
__zsh_prompt() {
331331
local prompt_username
332-
if [ ! -z "${GITHUB_USER}" ]; then
332+
if [ ! -z "${GITHUB_USER}" ]; then
333333
prompt_username="@${GITHUB_USER}"
334334
else
335335
prompt_username="%n"

.devcontainer/library-scripts/docker-debian.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ find_version_from_git_tags() {
8484
local repository=$2
8585
local prefix=${3:-"tags/v"}
8686
local separator=${4:-"."}
87-
local last_part_optional=${5:-"false"}
87+
local last_part_optional=${5:-"false"}
8888
if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then
8989
local escaped_separator=${separator//./\\.}
9090
local last_part
@@ -150,7 +150,7 @@ apt-get update
150150
if [ "${DOCKER_VERSION}" = "latest" ] || [ "${DOCKER_VERSION}" = "lts" ] || [ "${DOCKER_VERSION}" = "stable" ]; then
151151
# Empty, meaning grab whatever "latest" is in apt repo
152152
cli_version_suffix=""
153-
else
153+
else
154154
# Fetch a valid version from the apt-cache (eg: the Microsoft repo appends +azure, breakfix, etc...)
155155
docker_version_dot_escaped="${DOCKER_VERSION//./\\.}"
156156
docker_version_dot_plus_escaped="${docker_version_dot_escaped//+/\\+}"
@@ -205,7 +205,7 @@ else
205205
fi
206206
${pipx_bin} install --pip-args '--no-cache-dir --force-reinstall' docker-compose
207207
rm -rf /tmp/pip-tmp
208-
else
208+
else
209209
compose_v1_version="1"
210210
find_version_from_git_tags compose_v1_version "https://github.com/docker/compose" "tags/"
211211
echo "(*) Installing docker-compose ${compose_v1_version}..."
@@ -263,13 +263,13 @@ usermod -aG docker "${USERNAME}"
263263
DOCKER_GID="$(grep -oP '^docker:x:\K[^:]+' /etc/group)"
264264

265265
# If enabling non-root access and specified user is found, setup socat and add script
266-
chown -h "${USERNAME}":root "${TARGET_SOCKET}"
266+
chown -h "${USERNAME}":root "${TARGET_SOCKET}"
267267
if ! dpkg -s socat > /dev/null 2>&1; then
268268
apt_get_update_if_needed
269269
apt-get -y install socat
270270
fi
271271
tee /usr/local/share/docker-init.sh > /dev/null \
272-
<< EOF
272+
<< EOF
273273
#!/usr/bin/env bash
274274
#-------------------------------------------------------------------------------------------------------------
275275
# Copyright (c) Microsoft Corporation. All rights reserved.
@@ -301,8 +301,8 @@ log()
301301
echo -e "\n** \$(date) **" | sudoIf tee -a \${SOCAT_LOG} > /dev/null
302302
log "Ensuring ${USERNAME} has access to ${SOURCE_SOCKET} via ${TARGET_SOCKET}"
303303
304-
# If enabled, try to update the docker group with the right GID. If the group is root,
305-
# fall back on using socat to forward the docker socket to another unix socket so
304+
# If enabled, try to update the docker group with the right GID. If the group is root,
305+
# fall back on using socat to forward the docker socket to another unix socket so
306306
# that we can set permissions on it without affecting the host.
307307
if [ "${ENABLE_NONROOT_DOCKER}" = "true" ] && [ "${SOURCE_SOCKET}" != "${TARGET_SOCKET}" ] && [ "${USERNAME}" != "root" ] && [ "${USERNAME}" != "0" ]; then
308308
SOCKET_GID=\$(stat -c '%g' ${SOURCE_SOCKET})
@@ -322,7 +322,7 @@ if [ "${ENABLE_NONROOT_DOCKER}" = "true" ] && [ "${SOURCE_SOCKET}" != "${TARGET_
322322
log "Success"
323323
fi
324324
325-
# Execute whatever commands were passed in (if any). This allows us
325+
# Execute whatever commands were passed in (if any). This allows us
326326
# to set this script to ENTRYPOINT while still executing the default CMD.
327327
set +e
328328
exec "\$@"

.editorconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[*.fs]
22
indent_size=4
3-
max_line_length=120
3+
max_line_length=120
4+
5+
[*.sh]
6+
end_of_line = lf

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Auto detect text files and perform LF normalization
22
* text=auto
33

4+
# Make sure Bash files are checked out with LF line endings
5+
# See https://www.git-scm.com/docs/gitattributes#_eol
6+
*.sh eol=lf
7+
48
# Custom for Visual Studio
59
*.cs diff=csharp
610
*.sln merge=union

0 commit comments

Comments
 (0)