0

properties.ini

PROFILES="--spring.profiles.active=local"
PROPERTIES="--spring.config.import=file:./properties/"

script.sh

#!/bin/bash
# Read the INI file and set its values as variables
source /app/backend/properties.ini

/usr/bin/java -jar /app/backend/backend-api.jar $PROFILES $PROPERTIES

I have a bash script to run jar files.

Additionally, a properties.ini file exists to dynamically control environment variables.

Then I load this file with the source command and use it in the bash script.

But if you look at the code above,

PROFILES="--spring.profiles.active=local"

A problem occurs in this part.

If you hard-code this environment variable, there will be no problem, but if you load it through source, it will not work and an error will occur when running the jar.

If you try to output through echo, you can also check that it appears correctly.

While trying to fix this, I accidentally added "space" at the end and the problem went away.

Modified code:

properties.ini

PROFILES="--spring.profiles.active=local "  # << space
PROPERTIES="--spring.config.import=file:./properties/"

Other environment variables work correctly even without these spaces.

If you look at the command executed after that, that's a bit strange too. A dot is added after each environment variable.

root        4687       1 99 04:08 pts/2    00:00:21 /usr/bin/java -jar /app/backend/backend-api.jar --spring.profiles.active=local . --spring.config.import=file:./properties/.
  1. Unlike other environment variables, why does the profile environment variable require a final space?

  2. Why is the command executed like this appended with a dot?

0 Answers0