Skip to content

Commit

Permalink
chore: import.sh: make psql always use $SHELL when evaluating shell code
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Oct 9, 2024
1 parent d81cfdd commit d771aa4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,9 @@ RUN npm install --omit dev && npm cache clean --force

ADD . .

# When evaluating SQL scripts in postprocessing.d, import.sh passes $SHELL into psql explicitly, which in turn executes backtick-ed code blocks using $SHELL.
# Because the script inlined within those backticks/backquotes might rely on certain behavior, to achieve stability, we define this explicitly here, rather than relying on the implicit default from our base image.
ENV SHELL=/bin/bash

ENTRYPOINT []
CMD ["/usr/local/bin/node", "importer.js"]
2 changes: 1 addition & 1 deletion import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ if [ -d "$postprocessing_d_path" ]; then
for file in "$postprocessing_d_path/"*; do
ext="${file##*.}"
if [ "$ext" = "sql" ]; then
psql -b -1 -v 'ON_ERROR_STOP=1' "${psql_args[@]}" \
psql -b -1 -v 'ON_ERROR_STOP=1' --set=SHELL="$SHELL" "${psql_args[@]}" \
-f "$file"
else
"$file" "$gtfs_path"
Expand Down

0 comments on commit d771aa4

Please sign in to comment.