TOSIT-IO / tdp-getting-started

Vagrant / Ansible environment to deploy a local TDP cluster
Apache License 2.0
20 stars 24 forks source link

download_tdp_binaries skips last URI in setup.sh when tdp-release-uris.txt is missing a newline #283

Closed mohamedoud closed 1 year ago

mohamedoud commented 1 year ago

The download_tdp_binaries function in setup.sh seems to skip the last URI specified in tdp-release-uris.txt when the file does not end with a newline character.

Proposed solution:

Replace the existing loop:

while IFS=";" read -r uri_file_name file_name
do
  # ...
done < tdp-release-uris.txt

with the following loop that executes on successful read or if $uri_file_name is not empty:

while IFS=";" read -r uri_file_name file_name || [ -n "$uri_file_name" ]
do
  # ...
done < tdp-release-uris.txt
kpgtek commented 1 year ago

I have tried to add a newline in tdp-release-uris.txt, I could not have the issue. If tdp-release-uris.txt contains 3 lines without a newline, the function returns 3 lines, if tdp-release-uris.txt contains 3 lines with a newline, the function returns 4 lines and the last line is empty. Perharps my tests are not correct on my OS.

mohamedoud commented 1 year ago

By adding a newline at EOF, the problem will be solved. I was considering automating the process of reading the last line, so even if someone forgets to add it in future commits, it won't be a problem.

If the function acts differently on your OS, we might consider an alternative approach, such as using GitHub Action.