Skip to content

Commit 98660ee

Browse files
authored
build: increase scripts portability by migrating from bash to sh (#244)
1 parent ee6ad88 commit 98660ee

2 files changed

Lines changed: 32 additions & 24 deletions

File tree

docs/user-guide/mkdocs.sh

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
22
# This script aims to wrap MkDocs Material CLI through Docker in order to ensure portability across systems (Windows, Linux, Mac)
33

44
set -eu
55

6-
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
6+
SCRIPT_DIR=$(cd "$(dirname "$0")" > /dev/null 2>&1 && pwd -P)
77

8-
# Path conversion is required on Windows so that Docker volume mount will work
9-
# However, it shall be done in a controlled manner to avoid issues
10-
# Using Cygwin effectively with Windows: https://cygwin.com/cygwin-ug-net/using-effectively.html
11-
# Kernel detection is done based on the recommendation found here: https://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux
12-
if [[ "$(uname)" =~ (CYGWIN.*)|(MINGW.*)|(MSYS.*) ]]; then
13-
# We disable automatic path conversion to avoid unexpected side effects
14-
export MSYS_NO_PATHCONV=1
15-
# We manually enforce a Windows path to prevent issues with Docker volume mounts
16-
SCRIPT_DIR="$(cygpath --windows "${SCRIPT_DIR}")"
17-
fi
8+
# On Windows environments (Cygwin, MinGW, MSYS), Docker volume mounts require Windows-style paths.
9+
# However, automatic path conversion by MSYS can cause unexpected issues,
10+
# so we disable it and convert paths explicitly and deliberately.
11+
# See: https://cygwin.com/cygwin-ug-net/using-effectively.html
12+
# Kernel detection approach based on recommendations from:
13+
# https://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux
14+
case "$(uname)" in
15+
CYGWIN*|MINGW*|MSYS*)
16+
# We disable automatic path conversion to avoid unexpected side effects
17+
export MSYS_NO_PATHCONV=1
18+
# We manually enforce a Windows path to prevent issues with Docker volume mounts
19+
SCRIPT_DIR="$(cygpath --windows "${SCRIPT_DIR}")"
20+
;;
21+
esac
1822

1923
ROOT_PROJECT_DIR="${SCRIPT_DIR}/../.."
2024

docs/user-guide/requirements.sh

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
22
# This script aims to wrap pip-tools through Docker in order to ensure portability across systems (Windows, Linux, Mac)
33

44
set -eu
55

6-
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
6+
SCRIPT_DIR=$(cd "$(dirname "$0")" > /dev/null 2>&1 && pwd -P)
77

8-
# Path conversion is required on Windows so that Docker volume mount will work
9-
# However, it shall be done in a controlled manner to avoid issues
10-
# Using Cygwin effectively with Windows: https://cygwin.com/cygwin-ug-net/using-effectively.html
11-
# Kernel detection is done based on the recommendation found here: https://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux
12-
if [[ "$(uname)" =~ (CYGWIN.*)|(MINGW.*)|(MSYS.*) ]]; then
13-
# We disable automatic path conversion to avoid unexpected side effects
14-
export MSYS_NO_PATHCONV=1
15-
# We manually enforce a Windows path to prevent issues with Docker volume mounts
16-
SCRIPT_DIR="$(cygpath --windows "${SCRIPT_DIR}")"
17-
fi
8+
# On Windows environments (Cygwin, MinGW, MSYS), Docker volume mounts require Windows-style paths.
9+
# However, automatic path conversion by MSYS can cause unexpected issues,
10+
# so we disable it and convert paths explicitly and deliberately.
11+
# See: https://cygwin.com/cygwin-ug-net/using-effectively.html
12+
# Kernel detection approach based on recommendations from:
13+
# https://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux
14+
case "$(uname)" in
15+
CYGWIN*|MINGW*|MSYS*)
16+
# We disable automatic path conversion to avoid unexpected side effects
17+
export MSYS_NO_PATHCONV=1
18+
# We manually enforce a Windows path to prevent issues with Docker volume mounts
19+
SCRIPT_DIR="$(cygpath --windows "${SCRIPT_DIR}")"
20+
;;
21+
esac
1822

1923
docker build -t pip-tools -f Dockerfile.pip-tools "${SCRIPT_DIR}"
2024

0 commit comments

Comments
 (0)