Skip to content

Conversation

@kkimurak
Copy link
Owner

awk -F, splits values by comma but built-in for loop reinterpret each values. This behavior does not allow us to contain internal field separator (such as whitespace) in DB_EXTENSION and DB_NAME.

This PR set environment variable IFS (internal field separator that will affect to shell builtin functions) before / after corresponding for loop so that we can prevent unintended word splitting.

With this change, each element of DB_EXTENSION can include CREATE EXTENSION options.

Example usage (note that the extension vchord will require additional installation process so the container exits after the line):

$ docker run --rm --env 'DB_EXTENSION=btree_gist,pg_trgm,vchord CASCADE' --env 'DB_NAME=test' --env 'DB_USER=test_user' --env 'DB_PASS=password' kkimurak/sameersbn-postgresql:16-test
Initializing datadir...
Initializing certdir...
Initializing logdir...
Initializing rundir...
Setting resolv.conf ACLs...
Initializing database...
Configuring hot standby...
‣ Setting postgresql.conf parameter: wal_level = 'hot_standby'
‣ Setting postgresql.conf parameter: max_wal_senders = '16'
‣ Setting postgresql.conf parameter: checkpoint_segments = '8'
‣ Setting postgresql.conf parameter: wal_keep_segments = '32'
‣ Setting postgresql.conf parameter: hot_standby = 'on'
‣ Setting postgresql.conf parameter: data_directory = '/var/lib/postgresql/16/main'
‣ Setting postgresql.conf parameter: log_directory = '/var/log/postgresql'
‣ Setting postgresql.conf parameter: log_filename = 'postgresql-16-main.log'
‣ Setting postgresql.conf parameter: ssl = 'off'
Creating database user: test_user
Creating database: test...
‣ Loading btree_gist extension...
‣ Loading pg_trgm extension...
‣ Loading vchord CASCADE extension...

`awk -F,` splits values by comma but built-in for loop reinterpret each values.
This behavior does not allow us to contain internal field separator
(such as whitespace) in DB_EXTENSION for example.

By setting environment variable `IFS` we can control internal field separator
that will affect to for-in loop.
@kkimurak kkimurak merged commit 00e9dd2 into develop Jul 17, 2025
@kkimurak kkimurak deleted the issue/upstream/173-actual-comma-separated-iteration branch July 17, 2025 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants