0

I have a small test script that I am trying to run with sh. There are multiple variables which should be concatenated into one string in the end.

The sh script:

SECRETS_FILE_YAML="/my/file.yaml"
RCP_SECRETS_FILE_JSON="/my/another/file.json"
SPRING_ADDITIONAL_CONFIG="--spring.config.additional-location=file:${SECRETS_FILE_YAML}"
echo $SPRING_ADDITIONAL_CONFIG
RCP_FILE=",file:${RCP_SECRETS_FILE_JSON}"
echo $RCP_FILE
CONCAT="${SPRING_ADDITIONAL_CONFIG}${RCP_FILE}"
echo $CONCAT

The desired output is

--spring.config.additional-location=file:/my/file.yaml,file:/my/another/file.json

What I get instead is this:

--spring.config.additional-location=file:/my/file.yaml
,file:/my/another/file.json
,file:/my/another/file.jsonlocation=file:/my/file.yaml

I played with the concatenation, tried to use different methods, but none did the trick. It may be due to the way sh resolves variables or because of special characters in the strings. I do not understand how this result is produced though, not even the order of variables is correct when its printed.

Balu
  • 343
  • 3
  • 10
  • This is caused by DOS style carriage return line endings in your script. See the duplicate for how to find and remove them. – that other guy May 06 '22 at 16:35

0 Answers0