I have a simple script with while loop, but cannot understand, why it breaks after first line, from $vault_list variable:
#!/bin/bash
tech_login="$1"
vault_list=$(docker exec -i tmgnt_vault_1 vault list secret/${tech_login}-terminals | sed 1,2d)
while IFS= read -r terminal
do
echo "line is $terminal"
key_values=$(docker exec -i tmgnt_vault_1 vault read secret/${tech_login}-terminals/$terminal )
done <<< "$vault_list"
If I remove $key_values from while loop, it returns all values in echo "line is $terminal". Can anyone point me, what is the problem with while loop? I assume, that this can be a problem with output, but not sure.
With hint from @choroba I found right syntax for $key_values:
key_values=$(docker exec -i tmgnt_vault_1 vault read secret/${tech_login}-terminals/$terminal <<<$terminal)
I was need to pass the $terminal variable explicitly to the docker command, which can be done with a here-string, "<<