Skip to content

Commit 6038ec3

Browse files
satnam72jiridanek
andauthored
#1271: fix(scripts): posix noncompliance in nginx/root/usr/share/container-scripts/nginx/common.sh and duplicates of thereof (#1628)
* fix(nginx/common.sh) fix shell script that was not POSIX-complaint Let's rather add the `#!/usr/bin/env bash` and just use bash --------- Co-authored-by: Jiri Daněk <[email protected]>
1 parent 0124270 commit 6038ec3

File tree

4 files changed

+34
-28
lines changed
  • codeserver/ubi9-python-3.12/nginx/root/usr/share/container-scripts/nginx
  • rstudio
    • c9s-python-3.11/nginx/root/usr/share/container-scripts/nginx
    • rhel9-python-3.11/nginx/root/usr/share/container-scripts/nginx
  • tests

4 files changed

+34
-28
lines changed

codeserver/ubi9-python-3.12/nginx/root/usr/share/container-scripts/nginx/common.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22

33
# get_matched_files finds file for image extending
44
function get_matched_files() {
@@ -17,15 +17,15 @@ function process_extending_files() {
1717
local custom_dir default_dir
1818
custom_dir=$1
1919
default_dir=$2
20-
while read filename ; do
21-
if [ $filename ]; then
20+
while read -r filename ; do
21+
if [ "$filename" ]; then
2222
echo "=> sourcing $filename ..."
23-
# Custom file is prefered
24-
if [ -f $custom_dir/$filename ]; then
25-
source $custom_dir/$filename
26-
elif [ -f $default_dir/$filename ]; then
27-
source $default_dir/$filename
23+
# custom file has precedence
24+
if [ -f "$custom_dir/$filename" ]; then
25+
source "$custom_dir/$filename"
26+
elif [ -f "$default_dir/$filename" ]; then
27+
source "$default_dir/$filename"
2828
fi
2929
fi
3030
done <<<"$(get_matched_files "$custom_dir" "$default_dir" '*.sh' | sort -u)"
31-
}
31+
}

rstudio/c9s-python-3.11/nginx/root/usr/share/container-scripts/nginx/common.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22

33
# get_matched_files finds file for image extending
44
function get_matched_files() {
@@ -17,15 +17,15 @@ function process_extending_files() {
1717
local custom_dir default_dir
1818
custom_dir=$1
1919
default_dir=$2
20-
while read filename ; do
21-
if [ $filename ]; then
20+
while read -r filename ; do
21+
if [ "$filename" ]; then
2222
echo "=> sourcing $filename ..."
23-
# Custom file is prefered
24-
if [ -f $custom_dir/$filename ]; then
25-
source $custom_dir/$filename
26-
elif [ -f $default_dir/$filename ]; then
27-
source $default_dir/$filename
23+
# custom file has precedence
24+
if [ -f "$custom_dir/$filename" ]; then
25+
source "$custom_dir/$filename"
26+
elif [ -f "$default_dir/$filename" ]; then
27+
source "$default_dir/$filename"
2828
fi
2929
fi
3030
done <<<"$(get_matched_files "$custom_dir" "$default_dir" '*.sh' | sort -u)"
31-
}
31+
}

rstudio/rhel9-python-3.11/nginx/root/usr/share/container-scripts/nginx/common.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22

33
# get_matched_files finds file for image extending
44
function get_matched_files() {
@@ -17,15 +17,15 @@ function process_extending_files() {
1717
local custom_dir default_dir
1818
custom_dir=$1
1919
default_dir=$2
20-
while read filename ; do
21-
if [ $filename ]; then
20+
while read -r filename ; do
21+
if [ "$filename" ]; then
2222
echo "=> sourcing $filename ..."
23-
# Custom file is prefered
24-
if [ -f $custom_dir/$filename ]; then
25-
source $custom_dir/$filename
26-
elif [ -f $default_dir/$filename ]; then
27-
source $default_dir/$filename
23+
# custom file has precedence
24+
if [ -f "$custom_dir/$filename" ]; then
25+
source "$custom_dir/$filename"
26+
elif [ -f "$default_dir/$filename" ]; then
27+
source "$default_dir/$filename"
2828
fi
2929
fi
3030
done <<<"$(get_matched_files "$custom_dir" "$default_dir" '*.sh' | sort -u)"
31-
}
31+
}

tests/test_main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,17 @@ def test_files_that_should_be_same_are_same(subtests: pytest_subtests.plugin.Sub
321321
"ROCm de-vendor script": [
322322
PROJECT_ROOT / "jupyter/rocm/pytorch/ubi9-python-3.12/de-vendor-torch.sh",
323323
PROJECT_ROOT / "runtimes/rocm-pytorch/ubi9-python-3.12/de-vendor-torch.sh",
324-
]
324+
],
325+
"nginx/common.sh": [
326+
PROJECT_ROOT / "codeserver/ubi9-python-3.12/nginx/root/usr/share/container-scripts/nginx/common.sh",
327+
PROJECT_ROOT / "rstudio/c9s-python-3.11/nginx/root/usr/share/container-scripts/nginx/common.sh",
328+
PROJECT_ROOT / "rstudio/rhel9-python-3.11/nginx/root/usr/share/container-scripts/nginx/common.sh",
329+
],
325330
}
326331
for group_name, (first_file, *rest) in file_groups.items():
327332
with subtests.test(msg=f"Checking {group_name}"):
328333
for file in rest:
334+
# file.write_text(first_file.read_text()) # update rest according to first
329335
assert first_file.read_text() == file.read_text(), f"The files {first_file} and {file} do not match"
330336

331337

0 commit comments

Comments
 (0)