Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sed expression error #13

Open
dominicwa opened this issue Oct 15, 2021 · 2 comments
Open

sed expression error #13

dominicwa opened this issue Oct 15, 2021 · 2 comments

Comments

@dominicwa
Copy link

dominicwa commented Oct 15, 2021

start.sh generates an error:

sed: bad option in substitution expression

I thought it might be caused by PHP configs containing dots...

e.g.

if [ ! -z "$PHP_DATE_TIMEZONE" ]; then sed -i "s/\;\?\\s\?date.timezone = .*/date.timezone = $PHP_DATE_TIMEZONE/" /etc/php7/php.ini && echo "Set PHP date.timezone = $PHP_DATE_TIMEZONE..."; fi

But I've tried escaping the dots in the config name and it doesn't fix reliably (I'm getting inconsistent results, not sure exactly what's going on).

@dominicwa dominicwa changed the title sed expression error (inc. fix) sed expression error Oct 15, 2021
@dominicwa
Copy link
Author

I can't consistently replicate this issue. It's not even happening anymore.

In case it matters... I was noticing it in the container output on docker desktop (Mac).

@dominicwa
Copy link
Author

So I think there was a combination of factors causing this for me.

I'm fairly confident there's an extra space after the first equals sign in the sed statement above that is preventing the match to the date.timezone...

Changing to this...

if [ ! -z "$PHP_DATE_TIMEZONE" ]; then sed -i "s/\;\?\\s\?date.timezone =.*/date.timezone = $PHP_DATE_TIMEZONE/" /etc/php7/php.ini && echo "Set PHP date.timezone = $PHP_DATE_TIMEZONE..."; fi

That now catches it.

On top of that I was specifying my timezone env flag in the docker-compose like this...

- PHP_DATE_TIMEZONE=Australia/Perth

Or like this...

- PHP_DATE_TIMEZONE=Australia\/Perth

Neither worked. It needs to be this...

- 'PHP_DATE_TIMEZONE=Australia\/Perth'

(Notice both the escaping of the forward slash AND the single quotes around the whole key pair.

This is all super fiddly but the above now works consistently. Maybe it'll help someone else.

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

No branches or pull requests

1 participant