So I have a relatively simple bash script:
#!/bin/bash
declare ALL="";
while IFS="" read -r line || [ -n "$line" ]
do
if [[ $line == 'ENV ms'* ]]; then
words=( $line )
if [[ ${#ALL} > 0 ]]; then
ALL="$ALL;${words[1]}=${words[2]}"
else
ALL="${words[1]}=${words[2]}"
fi
if [[ ${#ALL} > 0 ]]; then
printf '%s\n' "$ALL"
echo "${#ALL}"
fi
fi
done < Dockerfile
echo "$ALL"
echo "${#ALL}"
parsing a Dockerfile that looks like this:
#
# Configuration Stage
#
FROM maven:3.6.1-jdk-12 AS build
ENV HOME=/usr/local/ms-cards
RUN mkdir -p $HOME
WORKDIR $HOME
COPY maven-settings.xml /root/.m2/settings.xml
COPY pom.xml $HOME
RUN mvn -Dmaven.test.skip=true clean verify --fail-never
COPY . $HOME
RUN mvn -Dmaven.test.skip=true clean package
#
# Package stage
#
FROM openjdk:12
COPY --from=build /usr/local/ms-cards/target/ms-cards-1.0-exec.jar /usr/local/lib/ms-cards.jar
ENV ms_oauth_ip ms-oauth
ENV ms_oauth_port 48001
ENV ms_cards_client_id clientapp
ENV ms_cards_client_secret 123456
ENV ms_cards_port 48002
ENV ms_connection_port 48003
ENV ms_connection_ip ms-connection
EXPOSE 48002
ENTRYPOINT ["java","-jar","/usr/local/lib/ms-cards.jar"]
and it gives me this output:
ms_oauth_ip=ms-oauth
21
;ms_oauth_port=48001
42
;ms_cards_client_id=clientapp
72
;ms_cards_client_secret=123456
103
;ms_cards_port=48002ret=123456
124
;ms_connection_port=4800323456
150
;ms_connection_ip=ms-connection
182
;ms_connection_ip=ms-connection
182
So I can see that my ALL variable is growing in length...but when printf'ing it never seems to be growing...Anyone know what I'm doing wrong?