-
Notifications
You must be signed in to change notification settings - Fork 105
Open
Description
Summary
The process_extending_files
function in codeserver/ubi9-python-3.12/nginx/root/usr/share/container-scripts/nginx/common.sh
has multiple portability and safety issues that should be addressed to improve code quality and POSIX compliance.
Issues Identified
Safety Issues
- Unquoted variables in test conditions:
[ $filename ]
breaks on spaces - Unquoted paths in file tests:
[ -f $custom_dir/$filename ]
causes word-splitting/globbing - Missing quotes in source commands:
source $custom_dir/$filename
Portability Issues
source
command is Bash-only; should use.
for POSIX compliance- Here-string loop construct (
<<<
) is Bash-only function
keyword is non-standardlocal
keyword is undefined in POSIX sh
Acceptance Criteria
- Quote all variable expansions in test conditions and source commands
- Replace
source
with.
for POSIX compliance OR update shebang to#!/bin/bash
if Bash is required - Replace here-string loop with POSIX-compatible while-read from pipe
- Remove non-standard
function
keyword - Address
local
keyword usage for POSIX compliance - Verify script works correctly after changes
Suggested Implementation
-while read filename ; do
- if [ $filename ]; then
+while read -r filename; do
+ if [ -n "$filename" ]; then
echo "=> sourcing $filename ..."
- if [ -f $custom_dir/$filename ]; then
- source $custom_dir/$filename
- elif [ -f $default_dir/$filename ]; then
- source $default_dir/$filename
+ if [ -f "$custom_dir/$filename" ]; then
+ source "$custom_dir/$filename"
+ elif [ -f "$default_dir/$filename" ]; then
+ source "$default_dir/$filename"
fi
fi
-done <<<"$(get_matched_files "$custom_dir" "$default_dir" '*.sh' | sort -u)"
+done < <(get_matched_files "$custom_dir" "$default_dir" '*.sh' | sort -u)
Context
- File:
codeserver/ubi9-python-3.12/nginx/root/usr/share/container-scripts/nginx/common.sh
- Function:
process_extending_files
(lines 16-30) - Origin: Code review feedback from PR RHOAIENG-22962: add code-server python 3.12 image #1269
- Original Comment: RHOAIENG-22962: add code-server python 3.12 image #1269 (comment)
Labels
- enhancement
- technical-debt
- shell-scripting
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
📋 Backlog